diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/a_time.c')
-rw-r--r-- | src/lib/libcrypto/asn1/a_time.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/lib/libcrypto/asn1/a_time.c b/src/lib/libcrypto/asn1/a_time.c index 7348da9457..159681fbcb 100644 --- a/src/lib/libcrypto/asn1/a_time.c +++ b/src/lib/libcrypto/asn1/a_time.c | |||
@@ -128,6 +128,7 @@ ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZE | |||
128 | { | 128 | { |
129 | ASN1_GENERALIZEDTIME *ret; | 129 | ASN1_GENERALIZEDTIME *ret; |
130 | char *str; | 130 | char *str; |
131 | int newlen; | ||
131 | 132 | ||
132 | if (!ASN1_TIME_check(t)) return NULL; | 133 | if (!ASN1_TIME_check(t)) return NULL; |
133 | 134 | ||
@@ -150,12 +151,14 @@ ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZE | |||
150 | /* grow the string */ | 151 | /* grow the string */ |
151 | if (!ASN1_STRING_set(ret, NULL, t->length + 2)) | 152 | if (!ASN1_STRING_set(ret, NULL, t->length + 2)) |
152 | return NULL; | 153 | return NULL; |
154 | /* ASN1_STRING_set() allocated 'len + 1' bytes. */ | ||
155 | newlen = t->length + 2 + 1; | ||
153 | str = (char *)ret->data; | 156 | str = (char *)ret->data; |
154 | /* Work out the century and prepend */ | 157 | /* Work out the century and prepend */ |
155 | if (t->data[0] >= '5') strcpy(str, "19"); | 158 | if (t->data[0] >= '5') BUF_strlcpy(str, "19", newlen); |
156 | else strcpy(str, "20"); | 159 | else BUF_strlcpy(str, "20", newlen); |
157 | 160 | ||
158 | BUF_strlcat(str, (char *)t->data, t->length+3); /* Include space for a '\0' */ | 161 | BUF_strlcat(str, (char *)t->data, newlen); |
159 | 162 | ||
160 | return ret; | 163 | return ret; |
161 | } | 164 | } |