From bdef0a4d2b3afdf8abc070fb1b962c78d3efcd11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Thu, 17 Apr 2003 07:12:24 +0000 Subject: [PATCH] remove sprintf git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12086 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/asn1/der_put.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/asn1/der_put.c b/lib/asn1/der_put.c index aea6f59cf..d10d02a05 100644 --- a/lib/asn1/der_put.c +++ b/lib/asn1/der_put.c @@ -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; }