- Added upstream-bugs.patch: upstream bug patches * Patches 2,3,4 - Added upstream-bugs-backport-lua54.patch: bugs discovered in lua54 * Patch 10: CVE-2020-24371, boo#1175449 * Patch 11: CVE-2020-24370, boo#1175448 * Patch 13 - Add RISC-V to list of 64-bit architectures OBS-URL: https://build.opensuse.org/request/show/827933 OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua53?expand=0&rev=34
83 lines
2.9 KiB
Diff
83 lines
2.9 KiB
Diff
--- a/src/ldebug.c
|
|
+++ b/src/ldebug.c
|
|
@@ -133,10 +133,11 @@ static const char *upvalname (Proto *p, int uv) {
|
|
|
|
static const char *findvararg (CallInfo *ci, int n, StkId *pos) {
|
|
int nparams = clLvalue(ci->func)->p->numparams;
|
|
- if (n >= cast_int(ci->u.l.base - ci->func) - nparams)
|
|
+ int nvararg = cast_int(ci->u.l.base - ci->func) - nparams;
|
|
+ if (n <= -nvararg)
|
|
return NULL; /* no such vararg */
|
|
else {
|
|
- *pos = ci->func + nparams + n;
|
|
+ *pos = ci->func + nparams - n;
|
|
return "(*vararg)"; /* generic name for any vararg */
|
|
}
|
|
}
|
|
@@ -148,7 +149,7 @@ static const char *findlocal (lua_State *L, CallInfo *ci, int n,
|
|
StkId base;
|
|
if (isLua(ci)) {
|
|
if (n < 0) /* access to vararg values? */
|
|
- return findvararg(ci, -n, pos);
|
|
+ return findvararg(ci, n, pos);
|
|
else {
|
|
base = ci->u.l.base;
|
|
name = luaF_getlocalname(ci_func(ci)->p, n, currentpc(ci));
|
|
--- a/src/liolib.c
|
|
+++ b/src/liolib.c
|
|
@@ -277,6 +277,8 @@ static int io_popen (lua_State *L) {
|
|
const char *filename = luaL_checkstring(L, 1);
|
|
const char *mode = luaL_optstring(L, 2, "r");
|
|
LStream *p = newprefile(L);
|
|
+ luaL_argcheck(L, ((mode[0] == 'r' || mode[0] == 'w') && mode[1] == '\0'),
|
|
+ 2, "invalid mode");
|
|
p->f = l_popen(L, filename, mode);
|
|
p->closef = &io_pclose;
|
|
return (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1;
|
|
--- a/src/lauxlib.c
|
|
+++ b/src/lauxlib.c
|
|
@@ -1013,10 +1013,10 @@ static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
|
|
}
|
|
else { /* cannot fail when shrinking a block */
|
|
void *newptr = realloc(ptr, nsize);
|
|
- if (newptr == NULL && ptr != NULL && nsize <= osize)
|
|
- return ptr; /* keep the original block */
|
|
- else /* no fail or not shrinking */
|
|
- return newptr; /* use the new block */
|
|
+ if (newptr == NULL && ptr != NULL && nsize <= osize)
|
|
+ return ptr; /* keep the original block */
|
|
+ else /* no fail or not shrinking */
|
|
+ return newptr; /* use the new block */
|
|
}
|
|
}
|
|
|
|
--- a/src/lundump.c
|
|
+++ b/src/lundump.c
|
|
@@ -86,6 +86,7 @@ static lua_Integer LoadInteger (LoadState *S) {
|
|
|
|
|
|
static TString *LoadString (LoadState *S, Proto *p) {
|
|
+ lua_State *L = S->L;
|
|
size_t size = LoadByte(S);
|
|
TString *ts;
|
|
if (size == 0xFF)
|
|
@@ -95,13 +96,16 @@ static TString *LoadString (LoadState *S, Proto *p) {
|
|
else if (--size <= LUAI_MAXSHORTLEN) { /* short string? */
|
|
char buff[LUAI_MAXSHORTLEN];
|
|
LoadVector(S, buff, size);
|
|
- ts = luaS_newlstr(S->L, buff, size);
|
|
+ ts = luaS_newlstr(L, buff, size);
|
|
}
|
|
else { /* long string */
|
|
- ts = luaS_createlngstrobj(S->L, size);
|
|
+ ts = luaS_createlngstrobj(L, size);
|
|
+ setsvalue2s(L, L->top, ts); /* anchor it ('loadVector' can GC) */
|
|
+ luaD_inctop(L);
|
|
LoadVector(S, getstr(ts), size); /* load directly in final place */
|
|
+ L->top--; /* pop string */
|
|
}
|
|
- luaC_objbarrier(S->L, p, ts);
|
|
+ luaC_objbarrier(L, p, ts);
|
|
return ts;
|
|
}
|