Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 334319
b: refs/heads/master
c: dbadc17
h: refs/heads/master
i:
  334317: 9b4f5b7
  334315: a2d8448
  334311: efab349
  334303: 863e255
v: v3
  • Loading branch information
David Howells authored and Rusty Russell committed Oct 10, 2012
1 parent f85f16d commit 18d4f74
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2f1c4fef103ef914e266588af263fb42b502b347
refs/heads/master: dbadc17683e6c673a69b236c0f041b931cc55c42
28 changes: 19 additions & 9 deletions trunk/lib/asn1_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,18 @@ static const unsigned char asn1_op_lengths[ASN1_OP__NR] = {

/*
* Find the length of an indefinite length object
* @data: The data buffer
* @datalen: The end of the innermost containing element in the buffer
* @_dp: The data parse cursor (updated before returning)
* @_len: Where to return the size of the element.
* @_errmsg: Where to return a pointer to an error message on error
*/
static int asn1_find_indefinite_length(const unsigned char *data, size_t datalen,
const char **_errmsg, size_t *_err_dp)
size_t *_dp, size_t *_len,
const char **_errmsg)
{
unsigned char tag, tmp;
size_t dp = 0, len, n;
size_t dp = *_dp, len, n;
int indef_level = 1;

next_tag:
Expand All @@ -67,8 +73,11 @@ static int asn1_find_indefinite_length(const unsigned char *data, size_t datalen
/* It appears to be an EOC. */
if (data[dp++] != 0)
goto invalid_eoc;
if (--indef_level <= 0)
return dp;
if (--indef_level <= 0) {
*_len = dp - *_dp;
*_dp = dp;
return 0;
}
goto next_tag;
}

Expand Down Expand Up @@ -122,7 +131,7 @@ static int asn1_find_indefinite_length(const unsigned char *data, size_t datalen
missing_eoc:
*_errmsg = "Missing EOC in indefinite len cons";
error:
*_err_dp = dp;
*_dp = dp;
return -1;
}

Expand Down Expand Up @@ -315,13 +324,14 @@ int asn1_ber_decoder(const struct asn1_decoder *decoder,
skip_data:
if (!(flags & FLAG_CONS)) {
if (flags & FLAG_INDEFINITE_LENGTH) {
len = asn1_find_indefinite_length(
data + dp, datalen - dp, &errmsg, &dp);
if (len < 0)
ret = asn1_find_indefinite_length(
data, datalen, &dp, &len, &errmsg);
if (ret < 0)
goto error;
} else {
dp += len;
}
pr_debug("- LEAF: %zu\n", len);
dp += len;
}
pc += asn1_op_lengths[op];
goto next_op;
Expand Down

0 comments on commit 18d4f74

Please sign in to comment.