summaryrefslogtreecommitdiff
path: root/apps/plugins/lua
diff options
context:
space:
mode:
authorWilliam Wilgus <me.theuser@yahoo.com>2019-08-28 00:56:08 -0500
committerWilliam Wilgus <me.theuser@yahoo.com>2019-08-28 00:56:08 -0500
commitc251d1879fd5f3b2705547182622ec19175ff1a7 (patch)
treead8f2b3b7b25c7e7682fa74d80aea9b6d4c61992 /apps/plugins/lua
parentb99d4d7fa900a4f6cebd5b87420e2831fdb5a4f3 (diff)
downloadrockbox-c251d1879fd5f3b2705547182622ec19175ff1a7.tar.gz
rockbox-c251d1879fd5f3b2705547182622ec19175ff1a7.zip
lua fix mem_read_write, strtol
back when I wrote this I was running the sim on a 32 bit machine I didn't catch the hardcoded LONG_MAX reference or the fact that lua_tointeger maxes ot at 32 bits on 64 bit machines strtol caused all kinds of issues especially since it returned the real LONG_MIN/MAX values Change-Id: I3571ebbd9df333f7cbf4077562412c27429bfadc
Diffstat (limited to 'apps/plugins/lua')
-rw-r--r--apps/plugins/lua/rocklib.c5
-rw-r--r--apps/plugins/lua/strtol.c2
2 files changed, 4 insertions, 3 deletions
diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c
index 8c662b7359..3c38440850 100644
--- a/apps/plugins/lua/rocklib.c
+++ b/apps/plugins/lua/rocklib.c
@@ -642,8 +642,8 @@ RB_WRAP(strncasecmp)
642 642
643static int mem_read_write(lua_State *L, uintptr_t address, size_t maxsize) 643static int mem_read_write(lua_State *L, uintptr_t address, size_t maxsize)
644{ 644{
645 intptr_t offset = (intptr_t) luaL_optint(L, 1, 0); 645 intptr_t offset = (intptr_t) luaL_optnumber(L, 1, 0);
646 size_t size = (size_t) luaL_optint(L, 2, maxsize); 646 size_t size = (size_t) luaL_optnumber(L, 2, maxsize);
647 size_t written; 647 size_t written;
648 int type = lua_type(L, 3); 648 int type = lua_type(L, 3);
649 649
@@ -651,6 +651,7 @@ static int mem_read_write(lua_State *L, uintptr_t address, size_t maxsize)
651 { 651 {
652 /* allows pointer within structure to be calculated offset */ 652 /* allows pointer within structure to be calculated offset */
653 offset = -(address + offset); 653 offset = -(address + offset);
654 luaL_argcheck(L, ((size_t) offset) <= maxsize, 1, ERR_IDX_RANGE);
654 size = (size_t) maxsize - offset; 655 size = (size_t) maxsize - offset;
655 } 656 }
656 657
diff --git a/apps/plugins/lua/strtol.c b/apps/plugins/lua/strtol.c
index 184951b844..3dd29b6b57 100644
--- a/apps/plugins/lua/strtol.c
+++ b/apps/plugins/lua/strtol.c
@@ -2,7 +2,7 @@
2 2
3extern unsigned long int strtoul(const char *ptr, char **endptr, int base); 3extern unsigned long int strtoul(const char *ptr, char **endptr, int base);
4 4
5#define ABS_LONG_MIN 2147483648UL 5#define ABS_LONG_MIN LONG_MAX
6long int strtol(const char *nptr, char **endptr, int base) 6long int strtol(const char *nptr, char **endptr, int base)
7{ 7{
8 int neg=0; 8 int neg=0;