diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2014-04-20 22:32:59 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2014-04-20 22:32:59 +0000 |
commit | 431f78b77959103b0a4416e70c3dac9566cd81c7 (patch) | |
tree | 46da798db2925ab36deee25dd9b9e4956b2db64d | |
parent | 5b48ff17484c198d3d6bac9de7618bbf56290dc0 (diff) |
replace a bunch of pointer-arithmatic-strcpy-converted-blindly-to-strlcpy
cruft with an snprintf.
"better than what was there" ok guenther@
-rw-r--r-- | lib/libcrypto/asn1/a_time.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/libcrypto/asn1/a_time.c b/lib/libcrypto/asn1/a_time.c index 29d56b827a8..080c3dfddb2 100644 --- a/lib/libcrypto/asn1/a_time.c +++ b/lib/libcrypto/asn1/a_time.c @@ -126,6 +126,7 @@ ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out) ASN1_GENERALIZEDTIME *ret; char *str; int newlen; + int i; if (!ASN1_TIME_check(t)) return NULL; @@ -151,13 +152,12 @@ ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out) /* ASN1_STRING_set() allocated 'len + 1' bytes. */ newlen = t->length + 2 + 1; str = (char *)ret->data; - /* Work out the century and prepend */ - if (t->data[0] >= '5') - strlcpy(str, "19", newlen); - else - strlcpy(str, "20", newlen); - strlcat(str, (char *)t->data, newlen); - + i = snprintf(str, newlen, "%s%s", (t->data >= '5') ? "19" : "20", + (char *) t->data); + if (i == -1 || i >= newlen) { + ASN1_STRING_free(ret); + return NULL; + } return ret; } |