Commit 75be34c2 authored by Niels Möller's avatar Niels Möller
Browse files

* src/parse.c (parse_bignum): New argument LIMIT.

Rev: src/parse.c:1.29
Rev: src/parse.h:1.22
parent d8ce6a6b
...@@ -196,7 +196,7 @@ parse_boolean(struct simple_buffer *buffer, int *result) ...@@ -196,7 +196,7 @@ parse_boolean(struct simple_buffer *buffer, int *result)
} }
int int
parse_bignum(struct simple_buffer *buffer, mpz_t result) parse_bignum(struct simple_buffer *buffer, mpz_t result, UINT32 limit)
{ {
UINT32 length; UINT32 length;
const UINT8 *digits; const UINT8 *digits;
...@@ -204,6 +204,9 @@ parse_bignum(struct simple_buffer *buffer, mpz_t result) ...@@ -204,6 +204,9 @@ parse_bignum(struct simple_buffer *buffer, mpz_t result)
if (!parse_string(buffer, &length, &digits)) if (!parse_string(buffer, &length, &digits))
return 0; return 0;
if (limit && (length > limit))
return 0;
bignum_parse_s(result, length, digits); bignum_parse_s(result, length, digits);
return 1; return 1;
......
...@@ -70,7 +70,7 @@ int parse_utf8(struct simple_buffer *buffer, UINT32 *result); ...@@ -70,7 +70,7 @@ int parse_utf8(struct simple_buffer *buffer, UINT32 *result);
int parse_boolean(struct simple_buffer *buffer, int *result); int parse_boolean(struct simple_buffer *buffer, int *result);
int parse_bignum(struct simple_buffer *buffer, mpz_t result); int parse_bignum(struct simple_buffer *buffer, mpz_t result, UINT32 limit);
int parse_atom(struct simple_buffer *buffer, int *result); int parse_atom(struct simple_buffer *buffer, int *result);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment