forked from osmocom/wireshark
catapult,irda: Fix ASAN crashes due to buffer underrun
The catapult dissector tripped on this random file I had. A quick look at other dissectors which use a construct like "-1] *= '*\\[rn]" showed packet-irda too, so fix that as well. Change-Id: I4b5fadcacd0b09d0fb29bdefc3dd1f28aef9b593 Reviewed-on: https://code.wireshark.org/review/2802 Reviewed-by: Evan Huus <eapache@gmail.com> Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
parent
6ed95406e3
commit
16f8ba1bed
|
@ -1651,14 +1651,14 @@ static void dissect_log(tvbuff_t* tvb, packet_info* pinfo, proto_tree* root)
|
|||
char buf[256];
|
||||
|
||||
|
||||
length = tvb_length(tvb);
|
||||
length = tvb_captured_length(tvb);
|
||||
if (length > sizeof(buf)-1)
|
||||
length = sizeof(buf)-1;
|
||||
tvb_memcpy(tvb, buf, 0, length);
|
||||
buf[length] = 0;
|
||||
if (buf[length-1] == '\n')
|
||||
if (length > 0 && buf[length-1] == '\n')
|
||||
buf[length-1] = 0;
|
||||
else if (buf[length-2] == '\n')
|
||||
else if (length > 1 && buf[length-2] == '\n')
|
||||
buf[length-2] = 0;
|
||||
|
||||
col_add_str(pinfo->cinfo, COL_INFO, buf);
|
||||
|
|
|
@ -805,12 +805,12 @@ read_new_line(FILE_T fh, gint64 *offset, gint *length,
|
|||
*offset = *offset + *length;
|
||||
|
||||
/* ...but don't want to include newline in line length */
|
||||
if (linebuff[*length-1] == '\n') {
|
||||
if (*length > 0 && linebuff[*length-1] == '\n') {
|
||||
linebuff[*length-1] = '\0';
|
||||
*length = *length - 1;
|
||||
}
|
||||
/* 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') {
|
||||
linebuff[*length-1] = '\0';
|
||||
*length = *length - 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue