aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2008-04-04 22:31:59 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2008-04-04 22:31:59 -0300
commit2b84e36b93841cac5b1d43cb7ec7324840f4fd59 (patch)
treedff0244aeba0ac519ef1919a7a9fe223343a8e7b
parent85bda9eef51e69384fe23114feaeeedfb6bb5f8c (diff)
downloadlua-2b84e36b93841cac5b1d43cb7ec7324840f4fd59.tar.gz
lua-2b84e36b93841cac5b1d43cb7ec7324840f4fd59.tar.bz2
lua-2b84e36b93841cac5b1d43cb7ec7324840f4fd59.zip
patches for some bugs
-rw-r--r--bugs101
1 files changed, 94 insertions, 7 deletions
diff --git a/bugs b/bugs
index a52ba06d..b57de4fc 100644
--- a/bugs
+++ b/bugs
@@ -1806,7 +1806,51 @@ a = string.dump(function()return;end)
1806a = a:gsub(string.char(30,37,122,128), string.char(34,0,0), 1) 1806a = a:gsub(string.char(30,37,122,128), string.char(34,0,0), 1)
1807loadstring(a)() 1807loadstring(a)()
1808]], 1808]],
1809patch = [[ ]], 1809patch = [[
1810--- ldebug.c 2007/12/28 15:32:23 2.29.1.3
1811+++ ldebug.c 2008/04/04 15:15:40
1812@@ -275,12 +275,12 @@
1813
1814 static int precheck (const Proto *pt) {
1815 check(pt->maxstacksize <= MAXSTACK);
1816- lua_assert(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize);
1817- lua_assert(!(pt->is_vararg & VARARG_NEEDSARG) ||
1818+ check(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize);
1819+ check(!(pt->is_vararg & VARARG_NEEDSARG) ||
1820 (pt->is_vararg & VARARG_HASARG));
1821 check(pt->sizeupvalues <= pt->nups);
1822 check(pt->sizelineinfo == pt->sizecode || pt->sizelineinfo == 0);
1823- check(GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN);
1824+ check(pt->sizecode > 0 && GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN);
1825 return 1;
1826 }
1827
1828@@ -363,7 +363,11 @@
1829 }
1830 switch (op) {
1831 case OP_LOADBOOL: {
1832- check(c == 0 || pc+2 < pt->sizecode); /* check its jump */
1833+ if (c == 1) { /* does it jump? */
1834+ check(pc+2 < pt->sizecode); /* check its jump */
1835+ check(GET_OPCODE(pt->code[pc+1]) != OP_SETLIST ||
1836+ GETARG_C(pt->code[pc+1]) != 0);
1837+ }
1838 break;
1839 }
1840 case OP_LOADNIL: {
1841@@ -428,7 +432,10 @@
1842 }
1843 case OP_SETLIST: {
1844 if (b > 0) checkreg(pt, a + b);
1845- if (c == 0) pc++;
1846+ if (c == 0) {
1847+ pc++;
1848+ check(pc < pt->sizecode - 1);
1849+ }
1850 break;
1851 }
1852 case OP_CLOSURE: {
1853]],
1810} 1854}
1811 1855
1812Bug{ 1856Bug{
@@ -1845,14 +1889,57 @@ z = 'if 1+1==2 then local a={' .. table.concat(z) .. '} end'
1845func = loadstring(z) 1889func = loadstring(z)
1846print(loadstring(string.dump(func))) 1890print(loadstring(string.dump(func)))
1847]], 1891]],
1848patch = [[ ]], 1892patch = [[
1893--- ldebug.c 2008/04/04 15:30:05 2.29.1.4
1894+++ ldebug.c 2008/04/04 15:47:10
1895@@ -346,9 +346,18 @@
1896 int dest = pc+1+b;
1897 check(0 <= dest && dest < pt->sizecode);
1898 if (dest > 0) {
1899- /* cannot jump to a setlist count */
1900- Instruction d = pt->code[dest-1];
1901- check(!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0));
1902+ int j;
1903+ /* check that it does not jump to a setlist count; this
1904+ is tricky, because the count from a previous setlist may
1905+ have the same value of an invalid setlist; so, we must
1906+ go all the way back to the first of them (if any) */
1907+ for (j = 0; j < dest; j++) {
1908+ Instruction d = pt->code[dest-1];
1909+ if (!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0)) break;
1910+ }
1911+ /* if 'j' is even, previous value is not a setlist (even if
1912+ it looks like one) */
1913+ check((j&1) == 0);
1914 }
1915 }
1916 break;
1917]],
1849} 1918}
1850 1919
1851Bug{ 1920Bug{
1852what = [[ ]], 1921what = [[maliciously crafted precompiled code can inject invalid boolean
1853report = [[ , on ]], 1922values into Lua code]],
1854since = [[i ]], 1923report = [[Greg Falcon, on 2008/03/27]],
1855example = [[ ]], 1924since = [[5.0]],
1856patch = [[ ]], 1925example = [[
1926maybe = string.dump(function() return ({[true]=true})[true] end)
1927maybe = maybe:gsub('\1\1','\1\2')
1928maybe = loadstring(maybe)()
1929assert(type(maybe) == "boolean" and maybe ~= true and maybe ~= false)
1930]],
1931patch = [[
1932--- lundump.c 2008/01/18 16:39:11 2.7.1.2
1933+++ lundump.c 2008/04/04 15:50:39
1934@@ -115,7 +115,7 @@
1935 setnilvalue(o);
1936 break;
1937 case LUA_TBOOLEAN:
1938- setbvalue(o,LoadChar(S));
1939+ setbvalue(o,LoadChar(S)!=0);
1940 break;
1941 case LUA_TNUMBER:
1942 setnvalue(o,LoadNumber(S));
1943]],
1857} 1944}
1858 1945