From 139c68d197203d885b005b4c9c3a3dbe844f7129 Mon Sep 17 00:00:00 2001 From: Sasha Szpakowski Date: Mon, 13 Feb 2023 19:41:25 -0400 Subject: [PATCH] better error checking for Data:getString's size parameter. --- src/modules/data/wrap_Data.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/modules/data/wrap_Data.cpp b/src/modules/data/wrap_Data.cpp index 507b4a28b..48a6570a4 100644 --- a/src/modules/data/wrap_Data.cpp +++ b/src/modules/data/wrap_Data.cpp @@ -45,6 +45,9 @@ int w_Data_getString(lua_State *L) ? ((int64) t->getSize() - offset) : (int64) luaL_checknumber(L, 3); + if (size <= 0) + return luaL_error(L, "Invalid size parameter (must be greater than 0)"); + if (offset < 0 || offset + size > (int64) t->getSize()) return luaL_error(L, "The given offset and size parameters don't fit within the Data's size.");