1
0
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:
J.-F. Cap 2019-02-26 02:28:24 +01:00
parent 3eb44f1f79
commit 59393fc73b

View File

@ -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;
}