summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/asn1/asn1_lib.c27
-rw-r--r--src/lib/libssl/src/crypto/asn1/asn1_lib.c27
2 files changed, 20 insertions, 34 deletions
diff --git a/src/lib/libcrypto/asn1/asn1_lib.c b/src/lib/libcrypto/asn1/asn1_lib.c
index 86cfdd3967..f3b2f0480f 100644
--- a/src/lib/libcrypto/asn1/asn1_lib.c
+++ b/src/lib/libcrypto/asn1/asn1_lib.c
@@ -373,7 +373,6 @@ ASN1_STRING_dup(const ASN1_STRING *str)
373int 373int
374ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len) 374ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
375{ 375{
376 unsigned char *c;
377 const char *data = _data; 376 const char *data = _data;
378 377
379 if (len < 0) { 378 if (len < 0) {
@@ -383,24 +382,19 @@ ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
383 len = strlen(data); 382 len = strlen(data);
384 } 383 }
385 if ((str->length < len) || (str->data == NULL)) { 384 if ((str->length < len) || (str->data == NULL)) {
386 c = str->data; 385 unsigned char *tmp;
387 if (c == NULL) 386 tmp = realloc(str->data, len + 1);
388 str->data = malloc(len + 1); 387 if (tmp == NULL) {
389 else
390 str->data = realloc(c, len + 1);
391
392 if (str->data == NULL) {
393 ASN1err(ASN1_F_ASN1_STRING_SET, ERR_R_MALLOC_FAILURE); 388 ASN1err(ASN1_F_ASN1_STRING_SET, ERR_R_MALLOC_FAILURE);
394 str->data = c;
395 return (0); 389 return (0);
396 } 390 }
391 str->data = tmp;
397 } 392 }
398 str->length = len; 393 str->length = len;
399 if (data != NULL) { 394 if (data != NULL) {
400 memcpy(str->data, data, len); 395 memmove(str->data, data, len);
401 /* an allowance for strings :-) */
402 str->data[len]='\0';
403 } 396 }
397 str->data[str->length]='\0';
404 return (1); 398 return (1);
405} 399}
406 400
@@ -465,11 +459,10 @@ ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b)
465void 459void
466asn1_add_error(const unsigned char *address, int offset) 460asn1_add_error(const unsigned char *address, int offset)
467{ 461{
468 char buf1[DECIMAL_SIZE(address) + 1], buf2[DECIMAL_SIZE(offset) + 1]; 462 char tmp[128];
469 463 (void) snprintf(tmp, sizeof(tmp), "address=%p offset=%d",
470 snprintf(buf1, sizeof buf1, "%lu", (unsigned long)address); 464 address, offset);
471 snprintf(buf2, sizeof buf2, "%d", offset); 465 ERR_add_error_data(1, tmp);
472 ERR_add_error_data(4, "address=", buf1, " offset=", buf2);
473} 466}
474 467
475int 468int
diff --git a/src/lib/libssl/src/crypto/asn1/asn1_lib.c b/src/lib/libssl/src/crypto/asn1/asn1_lib.c
index 86cfdd3967..f3b2f0480f 100644
--- a/src/lib/libssl/src/crypto/asn1/asn1_lib.c
+++ b/src/lib/libssl/src/crypto/asn1/asn1_lib.c
@@ -373,7 +373,6 @@ ASN1_STRING_dup(const ASN1_STRING *str)
373int 373int
374ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len) 374ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
375{ 375{
376 unsigned char *c;
377 const char *data = _data; 376 const char *data = _data;
378 377
379 if (len < 0) { 378 if (len < 0) {
@@ -383,24 +382,19 @@ ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
383 len = strlen(data); 382 len = strlen(data);
384 } 383 }
385 if ((str->length < len) || (str->data == NULL)) { 384 if ((str->length < len) || (str->data == NULL)) {
386 c = str->data; 385 unsigned char *tmp;
387 if (c == NULL) 386 tmp = realloc(str->data, len + 1);
388 str->data = malloc(len + 1); 387 if (tmp == NULL) {
389 else
390 str->data = realloc(c, len + 1);
391
392 if (str->data == NULL) {
393 ASN1err(ASN1_F_ASN1_STRING_SET, ERR_R_MALLOC_FAILURE); 388 ASN1err(ASN1_F_ASN1_STRING_SET, ERR_R_MALLOC_FAILURE);
394 str->data = c;
395 return (0); 389 return (0);
396 } 390 }
391 str->data = tmp;
397 } 392 }
398 str->length = len; 393 str->length = len;
399 if (data != NULL) { 394 if (data != NULL) {
400 memcpy(str->data, data, len); 395 memmove(str->data, data, len);
401 /* an allowance for strings :-) */
402 str->data[len]='\0';
403 } 396 }
397 str->data[str->length]='\0';
404 return (1); 398 return (1);
405} 399}
406 400
@@ -465,11 +459,10 @@ ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b)
465void 459void
466asn1_add_error(const unsigned char *address, int offset) 460asn1_add_error(const unsigned char *address, int offset)
467{ 461{
468 char buf1[DECIMAL_SIZE(address) + 1], buf2[DECIMAL_SIZE(offset) + 1]; 462 char tmp[128];
469 463 (void) snprintf(tmp, sizeof(tmp), "address=%p offset=%d",
470 snprintf(buf1, sizeof buf1, "%lu", (unsigned long)address); 464 address, offset);
471 snprintf(buf2, sizeof buf2, "%d", offset); 465 ERR_add_error_data(1, tmp);
472 ERR_add_error_data(4, "address=", buf1, " offset=", buf2);
473} 466}
474 467
475int 468int