remove sprintf
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12086 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -375,15 +375,18 @@ int
|
|||||||
time2generalizedtime (time_t t, octet_string *s)
|
time2generalizedtime (time_t t, octet_string *s)
|
||||||
{
|
{
|
||||||
struct tm *tm;
|
struct tm *tm;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
s->data = malloc(16);
|
len = 15;
|
||||||
|
|
||||||
|
s->data = malloc(len + 1);
|
||||||
if (s->data == NULL)
|
if (s->data == NULL)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
s->length = 15;
|
s->length = len;
|
||||||
tm = gmtime (&t);
|
tm = gmtime (&t);
|
||||||
sprintf (s->data, "%04d%02d%02d%02d%02d%02dZ", tm->tm_year + 1900,
|
snprintf (s->data, len + 1, "%04d%02d%02d%02d%02d%02dZ",
|
||||||
tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min,
|
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
|
||||||
tm->tm_sec);
|
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user