summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bugs64
-rw-r--r--lapi.c12
-rw-r--r--makefile4
3 files changed, 41 insertions, 39 deletions
diff --git a/bugs b/bugs
index 91899ce3..84cd3c2d 100644
--- a/bugs
+++ b/bugs
@@ -357,7 +357,7 @@ co = coroutine.create(co_func)
357coroutine.resume(co) 357coroutine.resume(co)
358coroutine.resume(co) --> seg. fault 358coroutine.resume(co) --> seg. fault
359]], 359]],
360report = [[by Alex Bilyk, 09/05/2003]], 360report = [[by Alex Bilyk, 09/05/2003]],
361patch = [[ 361patch = [[
362* ldo.c: 362* ldo.c:
363325,326c325 363325,326c325
@@ -399,7 +399,7 @@ what = [[file:close cannot be called without a file. (results in seg fault)]],
399example = [[ 399example = [[
400> io.stdin.close() -- correct call shold be io.stdin:close() 400> io.stdin.close() -- correct call shold be io.stdin:close()
401]], 401]],
402report = [[by Tuomo Valkonen, 27/05/2003]], 402report = [[by Tuomo Valkonen, 27/05/2003]],
403patch = [[ 403patch = [[
404* liolib.c: 404* liolib.c:
405161c161 405161c161
@@ -1641,7 +1641,7 @@ what = [[debug.sethook/gethook may overflow the thread's stack]],
1641report = [[Ivko Stanilov, on 2008/01/04]], 1641report = [[Ivko Stanilov, on 2008/01/04]],
1642since = [[5.1]], 1642since = [[5.1]],
1643example = [[ 1643example = [[
1644a = coroutine.create(function() yield() end) 1644a = coroutine.create(function() yield() end)
1645coroutine.resume(a) 1645coroutine.resume(a)
1646debug.sethook(a) -- may overflow the stack of 'a' 1646debug.sethook(a) -- may overflow the stack of 'a'
1647]], 1647]],
@@ -2707,7 +2707,7 @@ local firsttime = true
2707local function foo () 2707local function foo ()
2708 if firsttime then 2708 if firsttime then
2709 firsttime = false 2709 firsttime = false
2710 return "a = 1" 2710 return "a = 1"
2711 else 2711 else
2712 for i = 1, 10 do 2712 for i = 1, 10 do
2713 print(debug.getlocal(2, i)) 2713 print(debug.getlocal(2, i))
@@ -2899,28 +2899,6 @@ patch = [[
2899]] 2899]]
2900} 2900}
2901 2901
2902Bug{
2903what = [[Lua does not check memory use when creating error messages]],
2904report = [[John Dunn, 2012/09/24]],
2905since = [[5.2.0]],
2906fix = nil,
2907example = [[
2908local code = "function test()\n bob.joe.larry = 23\n end"
2909
2910load(code)()
2911
2912-- memory will grow steadly
2913for i = 1, math.huge do
2914 pcall(test)
2915 if i % 100000 == 0 then
2916 io.write(collectgarbage'count'*1024, "\n")
2917 end
2918end
2919]],
2920patch = [[
2921]]
2922}
2923
2924 2902
2925 2903
2926 2904
@@ -3859,11 +3837,11 @@ report = [[Viacheslav Usov, 2017/07/06]],
3859since = [[5.3.2]], 3837since = [[5.3.2]],
3860fix = nil, 3838fix = nil,
3861example = [[ 3839example = [[
3862function test() 3840function test()
3863 bob.joe.larry = 23 3841 bob.joe.larry = 23
3864end 3842end
3865 3843
3866-- memory will grow steadly 3844-- memory will grow steadly
3867for i = 1, math.huge do 3845for i = 1, math.huge do
3868 pcall(test) 3846 pcall(test)
3869 if i % 100000 == 0 then 3847 if i % 100000 == 0 then
@@ -3892,7 +3870,7 @@ report = [[云风 Cloud Wu, 2017/08/15]],
3892since = [[5.2]], 3870since = [[5.2]],
3893fix = nil, 3871fix = nil,
3894example = [[ 3872example = [[
3895-- The following chunk, under a memory checker like valgrind, 3873-- The following chunk, under a memory checker like valgrind,
3896-- produces a memory access violation. 3874-- produces a memory access violation.
3897 3875
3898local a = setmetatable({}, {__mode = 'kv'}) 3876local a = setmetatable({}, {__mode = 'kv'})
@@ -4020,7 +3998,6 @@ patch = [[
4020----------------------------------------------------------------- 3998-----------------------------------------------------------------
4021-- Lua 5.3.5 3999-- Lua 5.3.5
4022 4000
4023--[=[
4024Bug{ 4001Bug{
4025what = [[Long brackets with a huge number of '=' overflow some 4002what = [[Long brackets with a huge number of '=' overflow some
4026internal buffer arithmetic]], 4003internal buffer arithmetic]],
@@ -4111,9 +4088,34 @@ patch = [[
4111 } 4088 }
4112]] 4089]]
4113} 4090}
4114]=]
4115 4091
4116 4092
4093Bug{
4094what = [[joining an upvalue with itself can cause a use-after-free crash]],
4095report = [[Fady Othman, 2019/01/10]],
4096since = [[5.3]],
4097fix = nil,
4098example = [[
4099-- the next code may crash the machine
4100f=load(function() end)
4101interesting={}
4102interesting[0]=string.rep("A",512)
4103debug.upvaluejoin(f,1,f,1)
4104]],
4105patch = [[
4106--- a/lapi.c
4107+++ b/lapi.c
4108@@ -1289,6 +1289,8 @@ LUA_API void lua_upvaluejoin (lua_State *L, int fidx1, int n1,
4109 LClosure *f1;
4110 UpVal **up1 = getupvalref(L, fidx1, n1, &f1);
4111 UpVal **up2 = getupvalref(L, fidx2, n2, NULL);
4112+ if (*up1 == *up2)
4113+ return;
4114 luaC_upvdeccount(L, *up1);
4115 *up1 = *up2;
4116 (*up1)->refcount++;
4117]]
4118}
4117 4119
4118 4120
4119--[=[ 4121--[=[
diff --git a/lapi.c b/lapi.c
index 02b7fab7..711895b3 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1254,13 +1254,12 @@ LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) {
1254} 1254}
1255 1255
1256 1256
1257static UpVal **getupvalref (lua_State *L, int fidx, int n, LClosure **pf) { 1257static UpVal **getupvalref (lua_State *L, int fidx, int n) {
1258 LClosure *f; 1258 LClosure *f;
1259 StkId fi = index2addr(L, fidx); 1259 StkId fi = index2addr(L, fidx);
1260 api_check(L, ttisLclosure(fi), "Lua function expected"); 1260 api_check(L, ttisLclosure(fi), "Lua function expected");
1261 f = clLvalue(fi); 1261 f = clLvalue(fi);
1262 api_check(L, (1 <= n && n <= f->p->sizeupvalues), "invalid upvalue index"); 1262 api_check(L, (1 <= n && n <= f->p->sizeupvalues), "invalid upvalue index");
1263 if (pf) *pf = f;
1264 return &f->upvals[n - 1]; /* get its upvalue pointer */ 1263 return &f->upvals[n - 1]; /* get its upvalue pointer */
1265} 1264}
1266 1265
@@ -1269,7 +1268,7 @@ LUA_API void *lua_upvalueid (lua_State *L, int fidx, int n) {
1269 StkId fi = index2addr(L, fidx); 1268 StkId fi = index2addr(L, fidx);
1270 switch (ttype(fi)) { 1269 switch (ttype(fi)) {
1271 case LUA_TLCL: { /* lua closure */ 1270 case LUA_TLCL: { /* lua closure */
1272 return *getupvalref(L, fidx, n, NULL); 1271 return *getupvalref(L, fidx, n);
1273 } 1272 }
1274 case LUA_TCCL: { /* C closure */ 1273 case LUA_TCCL: { /* C closure */
1275 CClosure *f = clCvalue(fi); 1274 CClosure *f = clCvalue(fi);
@@ -1286,9 +1285,10 @@ LUA_API void *lua_upvalueid (lua_State *L, int fidx, int n) {
1286 1285
1287LUA_API void lua_upvaluejoin (lua_State *L, int fidx1, int n1, 1286LUA_API void lua_upvaluejoin (lua_State *L, int fidx1, int n1,
1288 int fidx2, int n2) { 1287 int fidx2, int n2) {
1289 LClosure *f1; 1288 UpVal **up1 = getupvalref(L, fidx1, n1);
1290 UpVal **up1 = getupvalref(L, fidx1, n1, &f1); 1289 UpVal **up2 = getupvalref(L, fidx2, n2);
1291 UpVal **up2 = getupvalref(L, fidx2, n2, NULL); 1290 if (*up1 == *up2)
1291 return;
1292 luaC_upvdeccount(L, *up1); 1292 luaC_upvdeccount(L, *up1);
1293 *up1 = *up2; 1293 *up1 = *up2;
1294 (*up1)->refcount++; 1294 (*up1)->refcount++;
diff --git a/makefile b/makefile
index 8160d4fb..7b619843 100644
--- a/makefile
+++ b/makefile
@@ -58,9 +58,9 @@ MYLDFLAGS= $(LOCAL) -Wl,-E
58MYLIBS= -ldl -lreadline 58MYLIBS= -ldl -lreadline
59 59
60 60
61CC= clang-3.8 61CC= gcc
62CFLAGS= -Wall -O2 $(MYCFLAGS) 62CFLAGS= -Wall -O2 $(MYCFLAGS)
63AR= ar rcu 63AR= ar rc
64RANLIB= ranlib 64RANLIB= ranlib
65RM= rm -f 65RM= rm -f
66 66