diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/a_time.c')
| -rw-r--r-- | src/lib/libcrypto/asn1/a_time.c | 10 |
1 files changed, 6 insertions, 4 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 | } |
