diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2007-10-29 13:51:10 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2007-10-29 13:51:10 -0200 |
commit | c06cc609466d4527848bbf87268ec714942d554a (patch) | |
tree | 34fa2d66dfaf077ab194a9b1c997a5deeb1910e9 /bugs | |
parent | 2fa476655fb1a733bcf8c408f14103bd7abed1b8 (diff) | |
download | lua-c06cc609466d4527848bbf87268ec714942d554a.tar.gz lua-c06cc609466d4527848bbf87268ec714942d554a.tar.bz2 lua-c06cc609466d4527848bbf87268ec714942d554a.zip |
BUG: 'gsub' may go wild when wrongly called without its third
> argument and with a large subject.
Diffstat (limited to 'bugs')
-rw-r--r-- | bugs | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -1539,6 +1539,37 @@ lua.c: | |||
1539 | } | 1539 | } |
1540 | 1540 | ||
1541 | Bug{ | 1541 | Bug{ |
1542 | what = [['gsub' may go wild when wrongly called without its third | ||
1543 | argument and with a large subject]], | ||
1544 | report = [[Florian Berger, on 10/2007]], | ||
1545 | since = [[5.1]], | ||
1546 | example = [[ | ||
1547 | x = string.rep('a', 10000) .. string.rep('b', 10000) | ||
1548 | print(#string.gsub(x, 'b')) | ||
1549 | ]], | ||
1550 | patch = [[ | ||
1551 | lstrlib.c: | ||
1552 | @@ -631,6 +631,2 @@ | ||
1553 | } | ||
1554 | - default: { | ||
1555 | - luaL_argerror(L, 3, "string/function/table expected"); | ||
1556 | - return; | ||
1557 | - } | ||
1558 | } | ||
1559 | @@ -650,2 +646,3 @@ | ||
1560 | const char *p = luaL_checkstring(L, 2); | ||
1561 | + int tr = lua_type(L, 3); | ||
1562 | int max_s = luaL_optint(L, 4, srcl+1); | ||
1563 | @@ -655,2 +652,5 @@ | ||
1564 | luaL_Buffer b; | ||
1565 | + luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING || | ||
1566 | + tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3, | ||
1567 | + "string/function/table expected"); | ||
1568 | luaL_buffinit(L, &b); | ||
1569 | ]], | ||
1570 | } | ||
1571 | |||
1572 | Bug{ | ||
1542 | what = [[ ]], | 1573 | what = [[ ]], |
1543 | report = [[ , on ]], | 1574 | report = [[ , on ]], |
1544 | since = [[i ]], | 1575 | since = [[i ]], |