summaryrefslogtreecommitdiff
path: root/deps/lua
Commit message (Collapse)AuthorAgeFilesLines
* Fix Lua compile warning on GCC 12.1 (#11115)Ozan Tezcan2022-08-141-1/+1
| | | | | | | | | | | | | | Fix Lua compile warning on GCC 12.1 GCC 12.1 prints a warning on compile: ``` ldump.c: In function ‘DumpString’: ldump.c:63:26: warning: the comparison will always evaluate as ‘false’ for the pointer operand in ‘s + 24’ must not be NULL [-Waddress] 63 | if (s==NULL || getstr(s)==NULL) ``` It seems correct, `getstr(s)` can't be `NULL`. Also, I see Lua v5.2 does not have that check: https://github.com/lua/lua/blob/v5-2/ldump.c#L63
* Fix Lua compile warning (#10805)Ozan Tezcan2022-06-011-1/+2
| | | | | | Apparently, GCC 11.2.0 has a new fancy warning for misleading indentations. It prints a warning when BRET(b) is on the same line as the loop.
* Protect any table which is reachable from globals and added globals white list.meir2022-04-272-0/+9
| | | | | | | | | | | The white list is done by setting a metatable on the global table before initializing any library. The metatable set the `__newindex` field to a function that check the white list before adding the field to the table. Fields which is not on the white list are simply ignored. After initialization phase is done we protect the global table and each table that might be reachable from the global table. For each table we also protect the table metatable if exists.
* Added support for Lua readonly tables.meir2022-04-276-2/+21
| | | | The new feature can be turned off and on using the new `lua_enablereadonlytable` Lua API.
* Fix Lua C API violation on lua msgpack lib. (#9832)Meir Shpilraien (Spielrein)2021-11-281-0/+1
| | | | | | | | | | | | | | | | | | | msgpack lib missed using lua_checkstack and so on rare cases overflow the stack by at most 2 elements. This is a violation of the Lua C API. Notice that Lua allocates additional 5 more elements on top of lua->stack_last so Redis does not access an invalid memory. But it is an API violation and we should avoid it. This PR also added a new Lua compilation option. The new option can be enable using environment variable called LUA_DEBUG. If set to `yes` (by default `no`), Lua will be compiled without optimizations and with debug symbols (`-O0 -g`). In addition, in this new mode, Lua will be compiled with the `-DLUA_USE_APICHECK` flag that enables extended Lua C API validations. In addition, set LUA_DEBUG=yes on daily valgrind flow so we will be able to catch Lua C API violations in the future.
* Lua: Use all characters to calculate string hash (#9449)Kamil Cudnik2021-09-091-1/+1
| | | | | For a lot of long strings which have same prefix which extends beyond hashing limit, there will be many hash collisions which result in performance degradation using commands like KEYS
* Fix compilation warnings in Lua and jemalloc dependencies (#7785)YoongHM2020-09-293-3/+3
| | | | | | | | | | - The argument `u` in for `ar` is ignored (and generates warnings since `D` became the default. All it does is avoid updating unchanged objects (shouldn't have any impact on our build) - Enable `LUA_USE_MKSTEMP` to force the use of `mkstemp()` instead of `tmpname()` (which is dead code in redis anyway). - Remove unused variable `c` in `f_parser()` - Removed misleadingly indented space in `luaL_loadfile()` and ``addfield()` Co-authored-by: Oran Agra <oran@redislabs.com>
* Backport Lua 5.2.2 stack overflow fix. (#7733)Yossi Gottlieb2020-08-311-1/+1
| | | | | This fixes the issue described in CVE-2014-5461. At this time we cannot confirm that the original issue has a real impact on Redis, but it is included as an extra safety measure.
* [FIX] revisit CVE-2015-8080 vulnerabilitySeunghoon Woo2020-02-101-4/+6
|
* Security: fix Lua struct package offset handling.antirez2018-06-131-2/+6
| | | | | | | | | | After the first fix to the struct package I found another similar problem, which is fixed by this patch. It could be reproduced easily by running the following script: return struct.unpack('f', "xxxxxxxxxxxxx",-3) The above will access bytes before the 'data' pointer.
* Security: more cmsgpack fixes by @soloestoy.antirez2018-06-131-0/+7
| | | | | | | @soloestoy sent me this additional fixes, after searching for similar problems to the one reported in mp_pack(). I'm committing the changes because it was not possible during to make a public PR to protect Redis users and give Redis providers some time to patch their systems.
* Security: update Lua struct package for security.antirez2018-06-131-23/+23
| | | | | | | | | | | | During an auditing Apple found that the "struct" Lua package we ship with Redis (http://www.inf.puc-rio.br/~roberto/struct/) contains a security problem. A bound-checking statement fails because of integer overflow. The bug exists since we initially integrated this package with Lua, when scripting was introduced, so every version of Redis with EVAL/EVALSHA capabilities exposed is affected. Instead of just fixing the bug, the library was updated to the latest version shipped by the author.
* Security: fix Lua cmsgpack library stack overflow.antirez2018-06-131-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During an auditing effort, the Apple Vulnerability Research team discovered a critical Redis security issue affecting the Lua scripting part of Redis. -- Description of the problem Several years ago I merged a pull request including many small changes at the Lua MsgPack library (that originally I authored myself). The Pull Request entered Redis in commit 90b6337c1, in 2014. Unfortunately one of the changes included a variadic Lua function that lacked the check for the available Lua C stack. As a result, calling the "pack" MsgPack library function with a large number of arguments, results into pushing into the Lua C stack a number of new values proportional to the number of arguments the function was called with. The pushed values, moreover, are controlled by untrusted user input. This in turn causes stack smashing which we believe to be exploitable, while not very deterministic, but it is likely that an exploit could be created targeting specific versions of Redis executables. However at its minimum the issue results in a DoS, crashing the Redis server. -- Versions affected Versions greater or equal to Redis 2.8.18 are affected. -- Reproducing Reproduce with this (based on the original reproduction script by Apple security team): https://gist.github.com/antirez/82445fcbea6d9b19f97014cc6cc79f8a -- Verification of the fix The fix was tested in the following way: 1) I checked that the problem is no longer observable running the trigger. 2) The Lua code was analyzed to understand the stack semantics, and that actually enough stack is allocated in all the cases of mp_pack() calls. 3) The mp_pack() function was modified in order to show exactly what items in the stack were being set, to make sure that there is no silent overflow even after the fix. -- Credits Thank you to the Apple team and to the other persons that helped me checking the patch and coordinating this communication.
* Remove Lua state reference from buffers in lua_cmsgpack.antirez2016-02-101-28/+25
|
* cmsgpack: pass correct osize values to lua allocator, update correct buf ↵yoav@monfort.co.il2016-02-071-4/+4
| | | | free space in cmsgpack
* lua_struct.c/getnum: throw error if overflow happenSun He2015-12-131-4/+6
| | | | Fix issue #2855
* disable loading lua bytecodeBen Murphy2015-06-031-1/+1
|
* Scripting: Lua cmsgpack lib updated to include str8 supportantirez2015-06-031-29/+42
|
* Lua cmsgpack lib updated to latest version.antirez2014-12-121-26/+27
| | | | | It fixes a bad bug that crashes the server in certain conditions as shown in issue #2210.
* Simplify lua_cmsgpack macro and fix build on old Linux distros.antirez2014-12-051-7/+1
| | | | Thanks to @badboy for the help in checking the build after the fix.
* Fix lua-cmsgpack 64 bit integer on 32 bit platformMatt Stancliff2014-11-241-14/+32
| | | | | | This syncs lua-cmsgpack with the mattsta/lua-cmsgpack upstream. Fixes #2161
* lua_cjson.c Lua includes: angled -> quoted.antirez2014-11-141-2/+2
|
* Merge remote-tracking branch 'origin/unstable' into unstableantirez2014-11-142-1/+191
|\
| * Lua: Add bitopMatt Stancliff2014-10-092-1/+191
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A few people have written custom C commands because bit manipulation isn't exposed through Lua. Let's give them Mike Pall's bitop. This adds bitop 1.0.2 (2012-05-08) from http://bitop.luajit.org/ bitop is imported as "bit" into the global namespace. New Lua commands: bit.tobit, bit.tohex, bit.bnot, bit.band, bit.bor, bit.bxor, bit.lshift, bit.rshift, bit.arshift, bit.rol, bit.ror, bit.bswap Verification of working (the asserts would abort on error, so (nil) is correct): 127.0.0.1:6379> eval "assert(bit.tobit(1) == 1); assert(bit.band(1) == 1); assert(bit.bxor(1,2) == 3); assert(bit.bor(1,2,4,8,16,32,64,128) == 255)" 0 (nil) 127.0.0.1:6379> eval 'assert(0x7fffffff == 2147483647, "broken hex literals"); assert(0xffffffff == -1 or 0xffffffff == 2^32-1, "broken hex literals"); assert(tostring(-1) == "-1", "broken tostring()"); assert(tostring(0xffffffff) == "-1" or tostring(0xffffffff) == "4294967295", "broken tostring()")' 0 (nil) Tests also integrated into the scripting tests and can be run with: ./runtest --single unit/scripting Tests are excerpted from `bittest.lua` included in the bitop distribution.
* | Lua: upgrade cmsgpack to 0.4.0Matt Stancliff2014-11-141-90/+305
| | | | | | | | | | | | | | | | Main reasons for upgrade: - Remove a warning when building Redis - Add multi pack/unpack - Improve memory usage and use Lua allocator properly - Fix some edge case encoding/decoding bugs
* | Lua: remove new warning added by cjson headerMatt Stancliff2014-11-141-1/+1
| | | | | | | | | | clang doesn't like "extern inline" when no definition is given right away.
* | Lua: Use Redis solaris compatability for cjson tooMatt Stancliff2014-11-141-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | cjson calls isinf, but some Solaris versions don't have isinf even with the attempted fix we have in deps/Makefile. We can harmlessly include the Redis solarisfixes.h header to give cjson proper isinf. Note: cjson has a compile-time setting for using their own defined isinf, but the Redis definition in solarisfixes.h is more complete. Fixes antirez#1620
* | Lua: Upgrade cjson to 2.1.0 (2012-03-01)Matt Stancliff2014-11-146-309/+674
|/ | | | | | | | | | | | | | | | | | The new cjson has some improvements over our current version including increased platform compatability, a new resource limit to restrict decode depth, and better invalid number handling. One minor change was required to deps/Makefile because this version of cjson doesn't export itself globally, so we added a quick little define of -DENABLE_CJSON_GLOBAL. cjson now has an optional higher performing float parsing interface, but we are not including it (g_fmt.c, dtoa.c) because it requires endianness declaration during compile time. This commit is exactly lua_cjson.c from 2.1.0 with one minor change of altering the two Lua includes for local search instead of system-wide importing.
* fix lua_cmsgpack pack map as arrayyihuang2013-08-271-1/+1
|
* Lua updated to version 5.1.5.antirez2013-04-2922-136/+194
|
* Inherit CC for LuaJohan Bergström2013-03-161-1/+1
|
* Lua struct library updated to version 0.2.antirez2013-01-231-52/+119
| | | | | | | | | | | | There was a bug in the previous version of this library that caused a crash under the circumstances described in issue #901. The newer version of the library appears to be fixed (I tested it manually with valgrind and everything seems fine now). For more information about this library please visit this web site: http://www.inf.puc-rio.br/~roberto/struct/
* lua_cmsgpack.c addedantirez2012-02-241-0/+729
|
* Lua_cmsgpack added to Redis scripting.antirez2012-02-241-1/+1
|
* added lua struct c extensionlsbardel2012-02-132-1/+355
|
* 32bit build fixed, broken by a previous commit fixing build on Solarisantirez2011-11-082-5/+5
|
* Lua cjson include paths now use the local includes.antirez2011-10-191-2/+2
|
* JSON support for Lua scripting, based on work from @lp, thanks!. We are ↵antirez2011-10-194-2/+1694
| | | | using the good and fast cjson by Mark Pulford.
* makefile adapted to link against lua lib and to pass the 32bit flag to Lua ↵antirez2011-05-25103-0/+28459
building system