diff options
| author | Mike Pall <mike> | 2026-01-09 17:34:15 +0100 |
|---|---|---|
| committer | Mike Pall <mike> | 2026-01-09 17:34:15 +0100 |
| commit | 221ea00775b2694dc088331a05ebb3c4273b182f (patch) | |
| tree | d2ebf9e18e7d7ddd65afddc7300896b93d8adcaf | |
| parent | 282e1a969daa343ed8c21904f275ee63becbf683 (diff) | |
| download | luajit-v2.0.tar.gz luajit-v2.0.tar.bz2 luajit-v2.0.zip | |
Note: this is not a vulnerability! minilua is only used during the LuaJIT
build process. It only runs controlled and static Lua code (DynASM),
which is entirely contained within this repo and does not trigger the
undefined behavior.
This change is solely for the benefit of others, who might possibly use
minilua for purposes other than running DynASM.
Reported by quart27219. #1424
| -rw-r--r-- | src/host/genminilua.lua | 4 | ||||
| -rw-r--r-- | src/host/minilua.c | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/host/genminilua.lua b/src/host/genminilua.lua index 2b0008ac..9e129148 100644 --- a/src/host/genminilua.lua +++ b/src/host/genminilua.lua | |||
| @@ -90,11 +90,11 @@ static int bswap(lua_State *L){ | |||
| 90 | UB b=barg(L,1);b=(b>>24)|((b>>8)&0xff00)|((b&0xff00)<<8)|(b<<24);BRET(b)} | 90 | UB b=barg(L,1);b=(b>>24)|((b>>8)&0xff00)|((b&0xff00)<<8)|(b<<24);BRET(b)} |
| 91 | static int tohex(lua_State *L){ | 91 | static int tohex(lua_State *L){ |
| 92 | UB b=barg(L,1); | 92 | UB b=barg(L,1); |
| 93 | int n=lua_isnone(L,2)?8:(int)barg(L,2); | 93 | UB n=lua_isnone(L,2)?8:barg(L,2); |
| 94 | const char *hexdigits="0123456789abcdef"; | 94 | const char *hexdigits="0123456789abcdef"; |
| 95 | char buf[8]; | 95 | char buf[8]; |
| 96 | int i; | 96 | int i; |
| 97 | if(n<0){n=-n;hexdigits="0123456789ABCDEF";} | 97 | if((int)n<0){n=~n+1;hexdigits="0123456789ABCDEF";} |
| 98 | if(n>8)n=8; | 98 | if(n>8)n=8; |
| 99 | for(i=(int)n;--i>=0;){buf[i]=hexdigits[b&15];b>>=4;} | 99 | for(i=(int)n;--i>=0;){buf[i]=hexdigits[b&15];b>>=4;} |
| 100 | lua_pushlstring(L,buf,(size_t)n); | 100 | lua_pushlstring(L,buf,(size_t)n); |
diff --git a/src/host/minilua.c b/src/host/minilua.c index 76f32aed..2d59de41 100644 --- a/src/host/minilua.c +++ b/src/host/minilua.c | |||
| @@ -7722,11 +7722,11 @@ static int bswap(lua_State*L){ | |||
| 7722 | UB b=barg(L,1);b=(b>>24)|((b>>8)&0xff00)|((b&0xff00)<<8)|(b<<24);BRET(b)} | 7722 | UB b=barg(L,1);b=(b>>24)|((b>>8)&0xff00)|((b&0xff00)<<8)|(b<<24);BRET(b)} |
| 7723 | static int tohex(lua_State*L){ | 7723 | static int tohex(lua_State*L){ |
| 7724 | UB b=barg(L,1); | 7724 | UB b=barg(L,1); |
| 7725 | int n=lua_isnone(L,2)?8:(int)barg(L,2); | 7725 | UB n=lua_isnone(L,2)?8:barg(L,2); |
| 7726 | const char*hexdigits="0123456789abcdef"; | 7726 | const char*hexdigits="0123456789abcdef"; |
| 7727 | char buf[8]; | 7727 | char buf[8]; |
| 7728 | int i; | 7728 | int i; |
| 7729 | if(n<0){n=-n;hexdigits="0123456789ABCDEF";} | 7729 | if((int)n<0){n=~n+1;hexdigits="0123456789ABCDEF";} |
| 7730 | if(n>8)n=8; | 7730 | if(n>8)n=8; |
| 7731 | for(i=(int)n;--i>=0;){buf[i]=hexdigits[b&15];b>>=4;} | 7731 | for(i=(int)n;--i>=0;){buf[i]=hexdigits[b&15];b>>=4;} |
| 7732 | lua_pushlstring(L,buf,(size_t)n); | 7732 | lua_pushlstring(L,buf,(size_t)n); |
