mirror of
https://github.com/janet-lang/janet
synced 2024-11-24 17:27:18 +00:00
Prevent unmarsal DOS in arrays,buffers,tables,and structs.
This commit is contained in:
parent
b145d47863
commit
c4ca0490ee
@ -1234,6 +1234,10 @@ static const uint8_t *unmarshal_one(
|
||||
{
|
||||
data++;
|
||||
int32_t len = readnat(st, &data);
|
||||
/* DOS check */
|
||||
if (lead != LB_REFERENCE) {
|
||||
MARSH_EOS(st, data - 1 + len);
|
||||
}
|
||||
if (lead == LB_ARRAY) {
|
||||
/* Array */
|
||||
JanetArray *array = janet_array(len);
|
||||
@ -1265,7 +1269,7 @@ static const uint8_t *unmarshal_one(
|
||||
*out = janet_wrap_struct(janet_struct_end(struct_));
|
||||
janet_v_push(st->lookup, *out);
|
||||
} else if (lead == LB_REFERENCE) {
|
||||
if (len < 0 || len >= janet_v_count(st->lookup))
|
||||
if (len >= janet_v_count(st->lookup))
|
||||
janet_panicf("invalid reference %d", len);
|
||||
*out = st->lookup[len];
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user