diff --git a/dependencies/tolua/tolua/01-tolua_tolua_open-proto-before-need.patch b/dependencies/tolua/tolua/01-tolua_tolua_open-proto-before-need.patch new file mode 100644 index 0000000..2ee3c1f --- /dev/null +++ b/dependencies/tolua/tolua/01-tolua_tolua_open-proto-before-need.patch @@ -0,0 +1,21 @@ +diff -Nurd tolua-5.2/src/bin/tolua.c tolua-5.2/src/bin/tolua.c +--- tolua-5.2/src/bin/tolua.c 2022-09-26 18:11:41.769267668 +0300 ++++ tolua-5.2/src/bin/tolua.c 2020-02-22 14:33:47.775736302 +0200 +@@ -22,6 +22,9 @@ + #include + #include + ++#ifndef LUA_SOURCE ++int tolua_tolua_open(lua_State *L); ++#endif + + static void help (void) + { +@@ -106,7 +109,6 @@ + + #ifndef LUA_SOURCE + { +- int tolua_tolua_open (lua_State* L); + tolua_tolua_open(L); + } + #else diff --git a/dependencies/tolua/tolua/02-fix-use-after-free.patch b/dependencies/tolua/tolua/02-fix-use-after-free.patch new file mode 100644 index 0000000..a6fb357 --- /dev/null +++ b/dependencies/tolua/tolua/02-fix-use-after-free.patch @@ -0,0 +1,13 @@ +diff -Nurd tolua-5.2/src/lib/tolua_event.c tolua-5.2/src/lib/tolua_event.c +--- tolua-5.2/src/lib/tolua_event.c 2022-09-26 18:17:40.544835582 +0300 ++++ tolua-5.2/src/lib/tolua_event.c 2022-08-29 15:10:32.145383356 +0300 +@@ -393,8 +393,8 @@ + } + else if (lua_isuserdata(L,-1) && *((void**)lua_touserdata(L,-1))==NULL) { + /* free object */ +- free(u); + tolua_release(L,u); /* unmap from tolua tables */ ++ free(u); + } + } + lua_settop(L,top); diff --git a/dependencies/tolua/tolua/03-tolua_bnd_takeownership-prototype.patch b/dependencies/tolua/tolua/03-tolua_bnd_takeownership-prototype.patch new file mode 100644 index 0000000..e431bd4 --- /dev/null +++ b/dependencies/tolua/tolua/03-tolua_bnd_takeownership-prototype.patch @@ -0,0 +1,11 @@ +diff -Nurd tolua-5.2/src/lib/tolua_map.c tolua-5.2/src/lib/tolua_map.c +--- tolua-5.2/src/lib/tolua_map.c 2022-09-26 18:19:26.145867532 +0300 ++++ tolua-5.2/src/lib/tolua_map.c 2020-02-22 14:33:47.779735894 +0200 +@@ -21,6 +21,7 @@ + #include + #include + ++int tolua_bnd_takeownership(lua_State *L); + + static char toluaname[128] = "tolua."; + static const char* TOLUANAME (const char* n) diff --git a/dependencies/tolua/tolua/04-include-tolua_event.patch b/dependencies/tolua/tolua/04-include-tolua_event.patch new file mode 100644 index 0000000..543d6f6 --- /dev/null +++ b/dependencies/tolua/tolua/04-include-tolua_event.patch @@ -0,0 +1,12 @@ +diff -Nurd tolua-5.2/src/lib/tolua_event.c tolua-5.2/src/lib/tolua_event.c +--- tolua-5.2/src/lib/tolua_event.c 2022-09-26 18:20:52.710709210 +0300 ++++ tolua-5.2/src/lib/tolua_event.c 2022-09-26 18:18:49.593511033 +0300 +@@ -18,6 +18,8 @@ + + #include "tolua.h" + ++#include "tolua_event.h" ++ + /* Store at peer + * It stores, creating the corresponding table if needed, + * the pair key/value in the corresponding peer table diff --git a/dependencies/tolua/tolua/05-gen-code-fix-null-dereferences.patch b/dependencies/tolua/tolua/05-gen-code-fix-null-dereferences.patch new file mode 100644 index 0000000..bb59af4 --- /dev/null +++ b/dependencies/tolua/tolua/05-gen-code-fix-null-dereferences.patch @@ -0,0 +1,27 @@ +diff -Nurd tolua-5.2/src/bin/lua/variable.lua tolua-5.2/src/bin/lua/variable.lua +--- tolua-5.2/src/bin/lua/variable.lua 2022-09-26 18:23:47.772402128 +0300 ++++ tolua-5.2/src/bin/lua/variable.lua 2022-08-29 15:10:32.145383356 +0300 +@@ -116,7 +116,10 @@ + -- check self value + if class and static==nil then + output('#ifndef TOLUA_RELEASE\n') +- output(' if (!self) tolua_error(tolua_S,"invalid \'self\' in accessing variable \''..self.name..'\'",NULL);'); ++ output(' if (!self) {\n') ++ output(' tolua_error(tolua_S,"invalid \'self\' in accessing variable \''..self.name..'\'",NULL);\n') ++ output(' return 0;\n') ++ output(' }\n') + output('#endif\n') + end + +@@ -163,7 +166,10 @@ + output('#ifndef TOLUA_RELEASE\n') + output(' tolua_Error tolua_err;') + if class and static==nil then +- output(' if (!self) tolua_error(tolua_S,"invalid \'self\' in accessing variable \''..self.name..'\'",NULL);'); ++ output(' if (!self) {\n') ++ output(' tolua_error(tolua_S,"invalid \'self\' in accessing variable \''..self.name..'\'",NULL);\n') ++ output(' return 0;\n') ++ output(' }\n') + elseif static then + _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)') + end diff --git a/dependencies/tolua/tolua_5.2.4.bb b/dependencies/tolua/tolua_5.2.4.bb index 0f0b8b0..fcd7bb6 100644 --- a/dependencies/tolua/tolua_5.2.4.bb +++ b/dependencies/tolua/tolua_5.2.4.bb @@ -1,5 +1,5 @@ SUMMARY = "Lua binding generator for C/C++" -DESCRIPTION = " tolua is a tool that greatly simplifies the integration of \ +DESCRIPTION = "Tolua is a tool that greatly simplifies the integration of \ C/C++ code with Lua. Based on a cleaned header file, tolua automatically \ generates the binding code to access C/C++ features from Lua. Using Lua API \ and tag method facilities, tolua maps C/C++ constants, external variables, \ @@ -13,15 +13,20 @@ BBCLASSEXTEND = "native" LICENSE = "GPL-2.0-or-later" LIC_FILES_CHKSUM = "file://include/tolua.h;beginline=9;endline=12;md5=4a3fbc0759a4b8318d99f3d71a773105" +# 0?- patches are from freeciv source tree. https://www.freeciv.org/ SRC_URI = "\ http://webserver2.tecgraf.puc-rio.br/~celes/tolua/tolua-${PV}.tar.gz \ file://MakefileFix.patch \ file://AllLuaPath.patch \ + file://01-tolua_tolua_open-proto-before-need.patch \ + file://02-fix-use-after-free.patch \ + file://03-tolua_bnd_takeownership-prototype.patch \ + file://04-include-tolua_event.patch \ + file://05-gen-code-fix-null-dereferences.patch \ " B = "${S}" -SRC_URI[md5sum] = "c8dcf13555df45bdcd792981d7356997" SRC_URI[sha256sum] = "c5a6b701b3ced9a66e7a9881c9d94430f8612040827650abe1aa3c5c3fc95bf2" EXTRA_OEMAKE = "STAGING_DIR_NATIVE=${STAGING_DIR_NATIVE}"