From 6bb2106b98eb0674d6726bb6917cea8c27ed9d81 Mon Sep 17 00:00:00 2001 From: ho <> Date: Thu, 3 Apr 2003 15:12:45 +0000 Subject: str{cat,cpy}/sprintf cleanup. markus@, deraadt@ ok --- src/lib/libcrypto/asn1/a_time.c | 10 ++++++---- src/lib/libcrypto/asn1/t_pkey.c | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src/lib/libcrypto/asn1') diff --git a/src/lib/libcrypto/asn1/a_time.c b/src/lib/libcrypto/asn1/a_time.c index 27ddd30899..f8fdfb5975 100644 --- a/src/lib/libcrypto/asn1/a_time.c +++ b/src/lib/libcrypto/asn1/a_time.c @@ -125,6 +125,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; @@ -145,14 +146,15 @@ ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZE } /* grow the string */ - if (!ASN1_STRING_set(ret, NULL, t->length + 2)) + newlen = t->length + 2; + if (!ASN1_STRING_set(ret, NULL, newlen)) return NULL; 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') strlcpy(str, "19", newlen); + else strlcpy(str, "20", newlen); - strcat(str, (char *)t->data); + strlcat(str, (char *)t->data, newlen); return ret; } diff --git a/src/lib/libcrypto/asn1/t_pkey.c b/src/lib/libcrypto/asn1/t_pkey.c index 2d46914cb1..b3f8364012 100644 --- a/src/lib/libcrypto/asn1/t_pkey.c +++ b/src/lib/libcrypto/asn1/t_pkey.c @@ -143,9 +143,9 @@ int RSA_print(BIO *bp, const RSA *x, int off) } if (x->d == NULL) - sprintf(str,"Modulus (%d bit):",BN_num_bits(x->n)); + snprintf(str,sizeof str,"Modulus (%d bit):",BN_num_bits(x->n)); else - strcpy(str,"modulus:"); + strlcpy(str,"modulus:",sizeof str); if (!print(bp,str,x->n,m,off)) goto err; s=(x->d == NULL)?"Exponent:":"publicExponent:"; if (!print(bp,s,x->e,m,off)) goto err; -- cgit v1.2.3-55-g6feb