diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2014-05-16 19:16:09 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2014-05-16 19:16:09 +0200 |
commit | 609d5c1366fb424f6150c4eed358d246e61cf204 (patch) | |
tree | 4c560c05fcdedd36f5d39fc55d9df8be17d0ab71 /lib/decoding.c | |
parent | cc10a8c5443c751d920cfaca1f104089e43296be (diff) | |
download | libtasn1-609d5c1366fb424f6150c4eed358d246e61cf204.tar.gz libtasn1-609d5c1366fb424f6150c4eed358d246e61cf204.tar.bz2 libtasn1-609d5c1366fb424f6150c4eed358d246e61cf204.zip |
Fixes in _asn1_extract_der_octet() and usage of DECR_LEN().
Diffstat (limited to 'lib/decoding.c')
-rw-r--r-- | lib/decoding.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/lib/decoding.c b/lib/decoding.c index bfc9dac..a6ed982 100644 --- a/lib/decoding.c +++ b/lib/decoding.c @@ -659,44 +659,51 @@ _asn1_extract_der_octet (asn1_node node, const unsigned char *der, int der_len) { int len2, len3; - int counter2, counter_end; + int counter, counter_end; + int result; len2 = asn1_get_length_der (der, der_len, &len3); if (len2 < -1) return ASN1_DER_ERROR; - counter2 = len3 + 1; + counter = len3 + 1; if (len2 == -1) counter_end = der_len - 2; else counter_end = der_len; - while (counter2 < counter_end) + while (counter < counter_end) { - len2 = asn1_get_length_der (der + counter2, der_len - counter2, &len3); + len2 = asn1_get_length_der (der + counter, der_len, &len3); if (len2 < -1) return ASN1_DER_ERROR; if (len2 > 0) { - _asn1_append_value (node, der + counter2 + len3, len2); + DECR_LEN(der_len, len2+len3); + _asn1_append_value (node, der + counter + len3, len2); } else { /* indefinite */ - - len2 = - _asn1_extract_der_octet (node, der + counter2 + len3, - der_len - counter2 - len3); - if (len2 < 0) - return len2; + DECR_LEN(der_len, len3); + result = + _asn1_extract_der_octet (node, der + counter + len3, + der_len); + if (result != ASN1_SUCCESS) + return result; + DECR_LEN(der_len, len2); } - counter2 += len2 + len3 + 1; + DECR_LEN(der_len, 1); + counter += len2 + len3 + 1; } return ASN1_SUCCESS; + +cleanup: + return result; } static int |