iseries: ensure the buffer is null terminated.

Check buflen to prevent wrong scanf call as well.

Bug: 15614
Change-Id: I58a2855d8b1beda067bf9b2d724229ab20249228
Reviewed-on: https://code.wireshark.org/review/32573
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Reviewed-by: João Valverde <j@v6e.pt>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
This commit is contained in:
Dario Lombardo 2019-03-25 10:20:10 +01:00
parent 8d3ac3af86
commit b39a736e91
2 changed files with 9 additions and 2 deletions

View File

@ -159,7 +159,7 @@ CHECKAPI(
NAME
wiretap
SWITCHES
--group abort:10 --summary-group abort
--group abort:11 --summary-group abort
--group termoutput:1 --summary-group termoutput
--build
SOURCES

View File

@ -431,6 +431,11 @@ iseries_seek_next_packet (wtap * wth, int *err, gchar **err_info)
buflen = (long) strlen (buf);
}
ascii_strup_inplace (buf);
/* Check we have enough data in the line */
if (buflen < 78)
{
continue;
}
/* If packet header found return the offset */
num_items_scanned =
sscanf (buf+78,
@ -985,8 +990,10 @@ iseries_UNICODE_to_ASCII (guint8 * buf, guint bytes)
bufptr++;
}
if (buf[i] == 0x0A)
return i;
break;
}
g_assert(bufptr < buf + bytes);
*bufptr = '\0';
return i;
}