make time2generalizedtime return an error code

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@9576 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
2001-01-29 08:31:27 +00:00
parent 55b30cf74e
commit 9fcb1a0934
2 changed files with 10 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997 - 2000 Kungliga Tekniska H<>gskolan * Copyright (c) 1997 - 2001 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden). * (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved. * All rights reserved.
* *
@@ -66,7 +66,7 @@ enum {
time_t timegm (struct tm *); time_t timegm (struct tm *);
#endif #endif
void time2generalizedtime (time_t t, octet_string *s); int time2generalizedtime (time_t t, octet_string *s);
int der_get_int (const unsigned char *p, size_t len, int *ret, size_t *size); int der_get_int (const unsigned char *p, size_t len, int *ret, size_t *size);
int der_get_length (const unsigned char *p, size_t len, int der_get_length (const unsigned char *p, size_t len,

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997 - 2000 Kungliga Tekniska H<>gskolan * Copyright (c) 1997 - 2001 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden). * (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved. * All rights reserved.
* *
@@ -293,17 +293,20 @@ encode_octet_string (unsigned char *p, size_t len,
return 0; return 0;
} }
void int
time2generalizedtime (time_t t, octet_string *s) time2generalizedtime (time_t t, octet_string *s)
{ {
struct tm *tm; struct tm *tm;
s->data = malloc(16); s->data = malloc(16);
if (s->data == NULL)
return ENOMEM;
s->length = 15; s->length = 15;
tm = gmtime (&t); tm = gmtime (&t);
sprintf (s->data, "%04d%02d%02d%02d%02d%02dZ", tm->tm_year + 1900, 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_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min,
tm->tm_sec); tm->tm_sec);
return 0;
} }
int int
@@ -315,7 +318,9 @@ encode_generalized_time (unsigned char *p, size_t len,
octet_string k; octet_string k;
int e; int e;
time2generalizedtime (*t, &k); e = time2generalizedtime (*t, &k);
if (e)
return e;
e = der_put_octet_string (p, len, &k, &l); e = der_put_octet_string (p, len, &k, &l);
free (k.data); free (k.data);
if (e) if (e)