diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2014-05-16 21:54:58 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2014-05-16 21:54:58 +0200 |
commit | 8596690b7885520d8d0b864e53cf94cc4051360a (patch) | |
tree | 78a6995f189bcee36a1442b9beeb243d6a1b3b6a /lib/element.c | |
parent | 92541f56adbdb56bbc97b07c2e073bbcd9f11b4a (diff) | |
download | libtasn1-8596690b7885520d8d0b864e53cf94cc4051360a.tar.gz libtasn1-8596690b7885520d8d0b864e53cf94cc4051360a.tar.bz2 libtasn1-8596690b7885520d8d0b864e53cf94cc4051360a.zip |
return the correct error code in asn1_read_value_type()
Diffstat (limited to 'lib/element.c')
-rw-r--r-- | lib/element.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/lib/element.c b/lib/element.c index 1fd988a..8062bce 100644 --- a/lib/element.c +++ b/lib/element.c @@ -790,7 +790,7 @@ asn1_read_value_type (asn1_node root, const char *name, void *ivalue, int *len, unsigned int *etype) { asn1_node node, p, p2; - int len2, len3; + int len2, len3, result; int value_size = *len; unsigned char *value = ivalue; unsigned type; @@ -848,9 +848,10 @@ asn1_read_value_type (asn1_node root, const char *name, void *ivalue, if ((isdigit (p->value[0])) || (p->value[0] == '-') || (p->value[0] == '+')) { - if (_asn1_convert_integer - (p->value, value, value_size, len) != ASN1_SUCCESS) - return ASN1_MEM_ERROR; + result = _asn1_convert_integer + (p->value, value, value_size, len); + if (result != ASN1_SUCCESS) + return result; } else { /* is an identifier like v1 */ @@ -861,10 +862,11 @@ asn1_read_value_type (asn1_node root, const char *name, void *ivalue, { if (!_asn1_strcmp (p2->name, p->value)) { - if (_asn1_convert_integer + result = _asn1_convert_integer (p2->value, value, value_size, - len) != ASN1_SUCCESS) - return ASN1_MEM_ERROR; + len); + if (result != ASN1_SUCCESS) + return result; break; } } @@ -875,10 +877,11 @@ asn1_read_value_type (asn1_node root, const char *name, void *ivalue, else { len2 = -1; - if (asn1_get_octet_der + result = asn1_get_octet_der (node->value, node->value_len, &len2, value, value_size, - len) != ASN1_SUCCESS) - return ASN1_MEM_ERROR; + len); + if (result != ASN1_SUCCESS) + return result; } break; case ASN1_ETYPE_OBJECT_ID: @@ -927,17 +930,19 @@ asn1_read_value_type (asn1_node root, const char *name, void *ivalue, case ASN1_ETYPE_UTF8_STRING: case ASN1_ETYPE_VISIBLE_STRING: len2 = -1; - if (asn1_get_octet_der + result = asn1_get_octet_der (node->value, node->value_len, &len2, value, value_size, - len) != ASN1_SUCCESS) - return ASN1_MEM_ERROR; + len); + if (result != ASN1_SUCCESS) + return result; break; case ASN1_ETYPE_BIT_STRING: len2 = -1; - if (asn1_get_bit_der + result = asn1_get_bit_der (node->value, node->value_len, &len2, value, value_size, - len) != ASN1_SUCCESS) - return ASN1_MEM_ERROR; + len); + if (result != ASN1_SUCCESS) + return result; break; case ASN1_ETYPE_CHOICE: PUT_STR_VALUE (value, value_size, node->down->name); |