aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/asn1/a_time.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2003-12-27 14:40:17 +0000
committerRichard Levitte <levitte@openssl.org>2003-12-27 14:40:17 +0000
commitd420ac2c7d4ba9d99ff2c257a3ad71ecc6d876e2 (patch)
tree84414c7d794c6286588d2042f060036378311348 /crypto/asn1/a_time.c
parentb79aa47a0c8478bea62fc2bb55f99e0be172da3d (diff)
downloadopenssl-d420ac2c7d4ba9d99ff2c257a3ad71ecc6d876e2.tar.gz
Use BUF_strlcpy() instead of strcpy().
Use BUF_strlcat() instead of strcat(). Use BIO_snprintf() instead of sprintf(). In some cases, keep better track of buffer lengths. This is part of a large change submitted by Markus Friedl <markus@openbsd.org>
Diffstat (limited to 'crypto/asn1/a_time.c')
-rw-r--r--crypto/asn1/a_time.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/crypto/asn1/a_time.c b/crypto/asn1/a_time.c
index 7348da9457..159681fbcb 100644
--- a/crypto/asn1/a_time.c
+++ b/crypto/asn1/a_time.c
@@ -128,6 +128,7 @@ ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZE
{
ASN1_GENERALIZEDTIME *ret;
char *str;
+ int newlen;
if (!ASN1_TIME_check(t)) return NULL;
@@ -150,12 +151,14 @@ ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZE
/* grow the string */
if (!ASN1_STRING_set(ret, NULL, t->length + 2))
return NULL;
+ /* 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') strcpy(str, "19");
- else strcpy(str, "20");
+ if (t->data[0] >= '5') BUF_strlcpy(str, "19", newlen);
+ else BUF_strlcpy(str, "20", newlen);
- BUF_strlcat(str, (char *)t->data, t->length+3); /* Include space for a '\0' */
+ BUF_strlcat(str, (char *)t->data, newlen);
return ret;
}