diff options
author | beck <> | 2014-04-16 20:36:35 +0000 |
---|---|---|
committer | beck <> | 2014-04-16 20:36:35 +0000 |
commit | 750d86a4fc04f53024575d65269281ea6c4e450c (patch) | |
tree | 4a8d2bd6f2dd786d658a75ea2db858806f2ec5f4 /src/lib/libcrypto/ts | |
parent | be77aa550ef0450b00eb62880d4d98112ba86e50 (diff) | |
download | openbsd-750d86a4fc04f53024575d65269281ea6c4e450c.tar.gz openbsd-750d86a4fc04f53024575d65269281ea6c4e450c.tar.bz2 openbsd-750d86a4fc04f53024575d65269281ea6c4e450c.zip |
Clean up dangerous strncpy use. This included a use where the resulting
string was potentially not nul terminated and a place where malloc return
was unchecked.
while we're at it remove dummytest.c
ok miod@
Diffstat (limited to 'src/lib/libcrypto/ts')
-rw-r--r-- | src/lib/libcrypto/ts/ts_rsp_verify.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/lib/libcrypto/ts/ts_rsp_verify.c b/src/lib/libcrypto/ts/ts_rsp_verify.c index a003207428..f241230ef4 100644 --- a/src/lib/libcrypto/ts/ts_rsp_verify.c +++ b/src/lib/libcrypto/ts/ts_rsp_verify.c | |||
@@ -538,7 +538,6 @@ static char *TS_get_status_text(STACK_OF(ASN1_UTF8STRING) *text) | |||
538 | int i; | 538 | int i; |
539 | unsigned int length = 0; | 539 | unsigned int length = 0; |
540 | char *result = NULL; | 540 | char *result = NULL; |
541 | char *p; | ||
542 | 541 | ||
543 | /* Determine length first. */ | 542 | /* Determine length first. */ |
544 | for (i = 0; i < sk_ASN1_UTF8STRING_num(text); ++i) | 543 | for (i = 0; i < sk_ASN1_UTF8STRING_num(text); ++i) |
@@ -554,17 +553,14 @@ static char *TS_get_status_text(STACK_OF(ASN1_UTF8STRING) *text) | |||
554 | return NULL; | 553 | return NULL; |
555 | } | 554 | } |
556 | /* Concatenate the descriptions. */ | 555 | /* Concatenate the descriptions. */ |
557 | for (i = 0, p = result; i < sk_ASN1_UTF8STRING_num(text); ++i) | 556 | result[0] = '\0'; |
557 | for (i = 0; i < sk_ASN1_UTF8STRING_num(text); ++i) | ||
558 | { | 558 | { |
559 | ASN1_UTF8STRING *current = sk_ASN1_UTF8STRING_value(text, i); | 559 | ASN1_UTF8STRING *current = sk_ASN1_UTF8STRING_value(text, i); |
560 | length = ASN1_STRING_length(current); | 560 | if (i > 0) |
561 | if (i > 0) *p++ = '/'; | 561 | strlcat(result, "/", length); |
562 | strncpy(p, (const char *)ASN1_STRING_data(current), length); | 562 | strlcat(result, ASN1_STRING_data(current), length); |
563 | p += length; | ||
564 | } | 563 | } |
565 | /* We do have space for this, too. */ | ||
566 | *p = '\0'; | ||
567 | |||
568 | return result; | 564 | return result; |
569 | } | 565 | } |
570 | 566 | ||