(der_parse_hex_heim_integer): make more resiliant to errors, handle
odd length numbers. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16571 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -51,17 +51,26 @@ der_parse_hex_heim_integer (const char *p, heim_integer *data)
|
||||
}
|
||||
|
||||
len = strlen(p);
|
||||
if (len < 0)
|
||||
if (len < 0) {
|
||||
data->data = NULL;
|
||||
data->length = 0;
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
data->length = len / 2;
|
||||
data->length = (len / 2) + 1;
|
||||
data->data = malloc(data->length);
|
||||
if (data->data == NULL)
|
||||
if (data->data == NULL) {
|
||||
data->length = 0;
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
len = hex_decode(p, data->data, data->length);
|
||||
if (len < 0)
|
||||
if (len < 0) {
|
||||
free(data->data);
|
||||
data->data = NULL;
|
||||
data->length = 0;
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
{
|
||||
unsigned char *p = data->data;
|
||||
|
Reference in New Issue
Block a user