netscaler: fix crash when reading malformed packets.

When reading a malformed packet, it can occur that we go close to
the end of the buffer. We need to check if we have 2 bytes before
reading a uint16.

Bug: 15497
Change-Id: I2b00f44933ca11b925ffbf05b9855684feebcda5
Reviewed-on: https://code.wireshark.org/review/32028
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Dario Lombardo 2019-02-18 14:34:28 +01:00 committed by Anders Broman
parent 22330a89b1
commit efe920af3a
1 changed files with 6 additions and 0 deletions

View File

@ -890,6 +890,12 @@ nspm_signature_version(wtap *wth, gchar *nstrace_buf, gint32 len)
{\
while (nstrace_buf_offset < nstrace_buflen)\
{\
/* check whether we have enough room to retrieve the recordType */\
if (nstrace_buflen - nstrace_buf_offset < 2) {\
*err = WTAP_ERR_BAD_FILE; \
*err_info = g_strdup("nstrace: malformed packet");\
return FALSE;\
}\
nspr_hd_v##ver##_t *fp = (nspr_hd_v##ver##_t *) &nstrace_buf[nstrace_buf_offset];\
switch (nspr_getv##ver##recordtype(fp))\
{\