diff options
author | beck <> | 2014-04-20 22:32:58 +0000 |
---|---|---|
committer | beck <> | 2014-04-20 22:32:58 +0000 |
commit | 27f49c1a7508baad456a0489c04d91b7804693e8 (patch) | |
tree | 982c4ca2815fe5769beb133c7326d2df09d3f005 /src/lib | |
parent | 6de4fe303d695d5fe59bc02038dbf0274979e6e7 (diff) | |
download | openbsd-27f49c1a7508baad456a0489c04d91b7804693e8.tar.gz openbsd-27f49c1a7508baad456a0489c04d91b7804693e8.tar.bz2 openbsd-27f49c1a7508baad456a0489c04d91b7804693e8.zip |
replace a bunch of pointer-arithmatic-strcpy-converted-blindly-to-strlcpy
cruft with an snprintf.
"better than what was there" ok guenther@
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libcrypto/asn1/a_time.c | 14 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/asn1/a_time.c | 14 |
2 files changed, 14 insertions, 14 deletions
diff --git a/src/lib/libcrypto/asn1/a_time.c b/src/lib/libcrypto/asn1/a_time.c index 29d56b827a..080c3dfddb 100644 --- a/src/lib/libcrypto/asn1/a_time.c +++ b/src/lib/libcrypto/asn1/a_time.c | |||
@@ -126,6 +126,7 @@ ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out) | |||
126 | ASN1_GENERALIZEDTIME *ret; | 126 | ASN1_GENERALIZEDTIME *ret; |
127 | char *str; | 127 | char *str; |
128 | int newlen; | 128 | int newlen; |
129 | int i; | ||
129 | 130 | ||
130 | if (!ASN1_TIME_check(t)) | 131 | if (!ASN1_TIME_check(t)) |
131 | return NULL; | 132 | return NULL; |
@@ -151,13 +152,12 @@ ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out) | |||
151 | /* ASN1_STRING_set() allocated 'len + 1' bytes. */ | 152 | /* ASN1_STRING_set() allocated 'len + 1' bytes. */ |
152 | newlen = t->length + 2 + 1; | 153 | newlen = t->length + 2 + 1; |
153 | str = (char *)ret->data; | 154 | str = (char *)ret->data; |
154 | /* Work out the century and prepend */ | 155 | i = snprintf(str, newlen, "%s%s", (t->data >= '5') ? "19" : "20", |
155 | if (t->data[0] >= '5') | 156 | (char *) t->data); |
156 | strlcpy(str, "19", newlen); | 157 | if (i == -1 || i >= newlen) { |
157 | else | 158 | ASN1_STRING_free(ret); |
158 | strlcpy(str, "20", newlen); | 159 | return NULL; |
159 | strlcat(str, (char *)t->data, newlen); | 160 | } |
160 | |||
161 | return ret; | 161 | return ret; |
162 | } | 162 | } |
163 | 163 | ||
diff --git a/src/lib/libssl/src/crypto/asn1/a_time.c b/src/lib/libssl/src/crypto/asn1/a_time.c index 29d56b827a..080c3dfddb 100644 --- a/src/lib/libssl/src/crypto/asn1/a_time.c +++ b/src/lib/libssl/src/crypto/asn1/a_time.c | |||
@@ -126,6 +126,7 @@ ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out) | |||
126 | ASN1_GENERALIZEDTIME *ret; | 126 | ASN1_GENERALIZEDTIME *ret; |
127 | char *str; | 127 | char *str; |
128 | int newlen; | 128 | int newlen; |
129 | int i; | ||
129 | 130 | ||
130 | if (!ASN1_TIME_check(t)) | 131 | if (!ASN1_TIME_check(t)) |
131 | return NULL; | 132 | return NULL; |
@@ -151,13 +152,12 @@ ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out) | |||
151 | /* ASN1_STRING_set() allocated 'len + 1' bytes. */ | 152 | /* ASN1_STRING_set() allocated 'len + 1' bytes. */ |
152 | newlen = t->length + 2 + 1; | 153 | newlen = t->length + 2 + 1; |
153 | str = (char *)ret->data; | 154 | str = (char *)ret->data; |
154 | /* Work out the century and prepend */ | 155 | i = snprintf(str, newlen, "%s%s", (t->data >= '5') ? "19" : "20", |
155 | if (t->data[0] >= '5') | 156 | (char *) t->data); |
156 | strlcpy(str, "19", newlen); | 157 | if (i == -1 || i >= newlen) { |
157 | else | 158 | ASN1_STRING_free(ret); |
158 | strlcpy(str, "20", newlen); | 159 | return NULL; |
159 | strlcat(str, (char *)t->data, newlen); | 160 | } |
160 | |||
161 | return ret; | 161 | return ret; |
162 | } | 162 | } |
163 | 163 | ||