potential buffer underflow in File_read_line function in epan/wslua/wslua_file.c

Putting up for review, though I am not completely convinced that
file_gets() can return an empty line.

Bug: 14295
Change-Id: If36761ea511b66c01a9f167809a218a7eadbfcc5
Reviewed-on: https://code.wireshark.org/review/24997
Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Martin Mathieson 2017-12-26 11:48:04 +00:00 committed by Anders Broman
parent 5153a7aba2
commit 137ab7d568
1 changed files with 1 additions and 1 deletions

View File

@ -192,7 +192,7 @@ static int File_read_line(lua_State *L, FILE_T ft) {
length = (gint)(file_tell(ft) - pos_before);
/* ...but don't want to include newline in line length */
if (linebuff[length-1] == '\n') {
if (length > 0 && linebuff[length-1] == '\n') {
length--;
/* Nor do we want '\r' (as will be written when log is created on windows) */
if (length > 0 && linebuff[length - 1] == '\r') {