Undefined behavior in utf8_decode()

Sergey Bronnikov <[email protected]>
Newsgroups gmane.comp.lang.lua.general
Message-ID <[email protected]>
Hello,

there is an issue with undefined behavior in lutf8lib.c because shift 
exponent may be too large for 32-bit type 'l_uint32':

lutf8lib.c:67:34: runtime error: shift exponent 35 is too large for 32-bit 
type 'l_uint32' (aka 'unsigned int')
    #0 0x56308fd6face in utf8_decode 
/src/testdir/build/lua-master/source/lutf8lib.c:67:34
    #1 0x56308fd6f4fd in utflen 
/src/testdir/build/lua-master/source/lutf8lib.c:99:22
    #2 0x56308fd05fe9 in precallC 
/src/testdir/build/lua-master/source/ldo.c:663:7
    #3 0x56308fd0687c in luaD_precall 
/src/testdir/build/lua-master/source/ldo.c
    #4 0x56308fd40413 in luaV_execute 
/src/testdir/build/lua-master/source/lvm.c:1729:22
    #5 0x56308fd06ce3 in ccall 
/src/testdir/build/lua-master/source/ldo.c:774:5
    #6 0x56308fd03b69 in luaD_rawrunprotected 
/src/testdir/build/lua-master/source/ldo.c:166:3
    #7 0x56308fd07cd8 in luaD_pcall 
/src/testdir/build/lua-master/source/ldo.c:1096:12
    #8 0x56308fcfaaa0 in lua_pcallk 
/src/testdir/build/lua-master/source/lapi.c:1097:14
    #9 0x56308fcf1435 in LLVMFuzzerTestOneInput 
/src/testdir/tests/capi/luaL_loadbuffer_test.c:34:3

Steps to reproduce:

make MYCFLAGS=-fsanitize=undefined MYLDFLAGS=-fsanitize=undefined
echo "dXRmOC5sZW4n2b0B/4+Pj4+Pj48AACc=" | base64 --decode | ./lua -

Lua version: c6b48482

Sergey

-- 
You received this message because you are subscribed to the Google Groups "lua-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/lua-l/26b14e5d-f8f4-4fd4-8c2a-6b30ee9f2329n%40googlegroups.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.