diff options
author | ho <> | 2003-04-03 15:12:45 +0000 |
---|---|---|
committer | ho <> | 2003-04-03 15:12:45 +0000 |
commit | 6bb2106b98eb0674d6726bb6917cea8c27ed9d81 (patch) | |
tree | 88a75b48f8926e146a6634e21b828e7345486c8c /src/lib/libcrypto/asn1 | |
parent | 030af986882598665482e3f4c559bdfd01f78eca (diff) | |
download | openbsd-6bb2106b98eb0674d6726bb6917cea8c27ed9d81.tar.gz openbsd-6bb2106b98eb0674d6726bb6917cea8c27ed9d81.tar.bz2 openbsd-6bb2106b98eb0674d6726bb6917cea8c27ed9d81.zip |
str{cat,cpy}/sprintf cleanup. markus@, deraadt@ ok
Diffstat (limited to 'src/lib/libcrypto/asn1')
-rw-r--r-- | src/lib/libcrypto/asn1/a_time.c | 10 | ||||
-rw-r--r-- | src/lib/libcrypto/asn1/t_pkey.c | 4 |
2 files changed, 8 insertions, 6 deletions
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 | |||
125 | { | 125 | { |
126 | ASN1_GENERALIZEDTIME *ret; | 126 | ASN1_GENERALIZEDTIME *ret; |
127 | char *str; | 127 | char *str; |
128 | int newlen; | ||
128 | 129 | ||
129 | if (!ASN1_TIME_check(t)) return NULL; | 130 | if (!ASN1_TIME_check(t)) return NULL; |
130 | 131 | ||
@@ -145,14 +146,15 @@ ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZE | |||
145 | } | 146 | } |
146 | 147 | ||
147 | /* grow the string */ | 148 | /* grow the string */ |
148 | if (!ASN1_STRING_set(ret, NULL, t->length + 2)) | 149 | newlen = t->length + 2; |
150 | if (!ASN1_STRING_set(ret, NULL, newlen)) | ||
149 | return NULL; | 151 | return NULL; |
150 | str = (char *)ret->data; | 152 | str = (char *)ret->data; |
151 | /* Work out the century and prepend */ | 153 | /* Work out the century and prepend */ |
152 | if (t->data[0] >= '5') strcpy(str, "19"); | 154 | if (t->data[0] >= '5') strlcpy(str, "19", newlen); |
153 | else strcpy(str, "20"); | 155 | else strlcpy(str, "20", newlen); |
154 | 156 | ||
155 | strcat(str, (char *)t->data); | 157 | strlcat(str, (char *)t->data, newlen); |
156 | 158 | ||
157 | return ret; | 159 | return ret; |
158 | } | 160 | } |
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) | |||
143 | } | 143 | } |
144 | 144 | ||
145 | if (x->d == NULL) | 145 | if (x->d == NULL) |
146 | sprintf(str,"Modulus (%d bit):",BN_num_bits(x->n)); | 146 | snprintf(str,sizeof str,"Modulus (%d bit):",BN_num_bits(x->n)); |
147 | else | 147 | else |
148 | strcpy(str,"modulus:"); | 148 | strlcpy(str,"modulus:",sizeof str); |
149 | if (!print(bp,str,x->n,m,off)) goto err; | 149 | if (!print(bp,str,x->n,m,off)) goto err; |
150 | s=(x->d == NULL)?"Exponent:":"publicExponent:"; | 150 | s=(x->d == NULL)?"Exponent:":"publicExponent:"; |
151 | if (!print(bp,s,x->e,m,off)) goto err; | 151 | if (!print(bp,s,x->e,m,off)) goto err; |