lua: lnum: fix strtoul based number parsing
authorLiangbin Lian <jjm2473@gmail.com>
Tue, 14 May 2019 15:20:45 +0000 (23:20 +0800)
committerPetr Štetiar <ynezz@true.cz>
Thu, 23 May 2019 08:19:52 +0000 (10:19 +0200)
commit4bb9af48ca36605424c57b6af27dd5e5c827395f
tree6380d7f6b84fae2021d9aecc7c8f718079848ad7
parent33b81b572148e2de52fbcb986e238c2efbd1939f
lua: lnum: fix strtoul based number parsing

Lua's LNUM patch currently doesn't parse properly certain numbers as
it's visible from the following simple tests.

On x86_64 host (stock Lua 5.1.5, expected output):

 $ /usr/bin/lua -e 'print(0x80000000); print(0x80000000000); print(0x100000000)'

  2147483648
  8796093022208
  4294967296

On x86_64 host:

 $ staging_dir/hostpkg/bin/lua -e 'print(0x80000000); print(0x80000000000); print(0x100000000)'

  -2147483648
  0
  0

On x86_64 target:

 $ lua -e 'print(0x80000000); print(0x80000000000); print(0x100000000)'

  -2147483648
  0
  0

On ath79 target:

 $ lua -e 'print(0x80000000); print(0x80000000000); print(0x100000000)'

  -2147483648
  8796093022208
  4294967296

It's caused by two issues fixed in this patch, first issue is caused by
unhadled strtoul overflow and second one is caused by the cast of
unsigned to signed Lua integer when parsing from hex literal.

Run tested on:

 * Zidoo Z9S with RTD1296 CPU (aarch64_cortex-a53)
 * qemu/x86_64
 * qemu/armvirt_64
 * ath79

Signed-off-by: Liangbin Lian <jjm2473@gmail.com>
[commit subject/message touches, fixed From to match SOB, fixed another
 unhandled case in luaO_str2i, host Lua, package bump]
Signed-off-by: Petr Štetiar <ynezz@true.cz>
package/utils/lua/Makefile
package/utils/lua/patches-host/013-lnum-strtoul-parsing-fixes.patch [new file with mode: 0644]
package/utils/lua/patches/013-lnum-strtoul-parsing-fixes.patch [new file with mode: 0644]