(der_get_time): avoid using wrapping of octet_string and realloc.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21369 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2007-06-27 10:14:39 +00:00
parent 25bd294397
commit 9ab118ca78

View File

@@ -341,26 +341,20 @@ static int
der_get_time (const unsigned char *p, size_t len,
time_t *data, size_t *size)
{
heim_octet_string k;
char *times;
size_t ret = 0;
size_t l;
int e;
e = der_get_octet_string (p, len, &k, &l);
if (e) return e;
p += l;
len -= l;
ret += l;
times = realloc(k.data, k.length + 1);
if (times == NULL){
free(k.data);
if (len > len + 1 || len == 0)
return ASN1_BAD_LENGTH;
times = malloc(len + 1);
if (times == NULL)
return ENOMEM;
}
times[k.length] = 0;
memcpy(times, p, len);
times[len] = '\0';
e = generalizedtime2time(times, data);
free (times);
if(size) *size = ret;
if(size) *size = len;
return e;
}