diff options
Diffstat (limited to 'crypto/heimdal/lib/asn1/der_put.c')
-rw-r--r-- | crypto/heimdal/lib/asn1/der_put.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/crypto/heimdal/lib/asn1/der_put.c b/crypto/heimdal/lib/asn1/der_put.c index 1dfafdc..41733c5 100644 --- a/crypto/heimdal/lib/asn1/der_put.c +++ b/crypto/heimdal/lib/asn1/der_put.c @@ -33,7 +33,7 @@ #include "der_locl.h" -RCSID("$Id: der_put.c,v 1.27 2001/09/25 23:37:25 assar Exp $"); +RCSID("$Id: der_put.c,v 1.28 2003/04/17 07:12:24 lha Exp $"); /* * All encoding functions take a pointer `p' to first position in @@ -375,15 +375,18 @@ int time2generalizedtime (time_t t, octet_string *s) { struct tm *tm; + size_t len; - s->data = malloc(16); + len = 15; + + s->data = malloc(len + 1); if (s->data == NULL) return ENOMEM; - s->length = 15; + s->length = len; tm = gmtime (&t); - sprintf (s->data, "%04d%02d%02d%02d%02d%02dZ", tm->tm_year + 1900, - tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, - tm->tm_sec); + snprintf (s->data, len + 1, "%04d%02d%02d%02d%02d%02dZ", + tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec); return 0; } |