mirror of
https://github.com/janet-lang/janet
synced 2024-11-29 03:19:54 +00:00
Added some guards in ta_view unmarshalling
to protect against bad marshalled data.
This commit is contained in:
parent
3eb44f1f79
commit
59393fc73b
@ -165,6 +165,9 @@ static void ta_view_unmarshal(void *p, JanetMarshalContext *ctx) {
|
||||
janet_unmarshal_size(ctx, &offset);
|
||||
janet_unmarshal_janet(ctx, &buffer);
|
||||
view->buffer = (JanetTArrayBuffer *)janet_unwrap_abstract(buffer);
|
||||
size_t buf_need_size = offset + (janet_tarray_type_size(view->type)) * ((view->size - 1) * view->stride + 1);
|
||||
if (view->buffer->size < buf_need_size)
|
||||
janet_panic("bad typed array offset in marshalled data");
|
||||
view->data = view->buffer->data + offset;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user