forked from osmocom/wireshark
lua: fix buffer underrun
A line containing just "\n" will cause a buffer underrun. Test: tshark -r test/captures/sipmsg.log -X lua_script:test/lua/acme_file.lua -w /dev/null Caught by ASAN. Change-Id: Idf38f1af2b211101b3929ee3fbd83c54c99c1e21 Reviewed-on: https://code.wireshark.org/review/1673 Reviewed-by: Evan Huus <eapache@gmail.com>
This commit is contained in:
parent
cea149aa89
commit
24082972a3
|
@ -192,7 +192,7 @@ static int File_read_line(lua_State *L, FILE_T ft) {
|
|||
if (linebuff[length-1] == '\n') {
|
||||
length--;
|
||||
/* Nor do we want '\r' (as will be written when log is created on windows) */
|
||||
if (linebuff[length-1] == '\r') {
|
||||
if (length > 0 && linebuff[length - 1] == '\r') {
|
||||
length--;
|
||||
}
|
||||
linebuff[length] = '\0';
|
||||
|
|
Loading…
Reference in New Issue