diff options
author | Guy Harris <guy@alum.mit.edu> | 2015-11-29 20:29:55 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2015-11-30 04:30:25 +0000 |
commit | 943be4b755d46fa348bea3474af503c3b9f6dc39 (patch) | |
tree | ee62c67f496394a606def8d1883d86396da643c3 /wiretap/iseries.c | |
parent | 338da1c0ea0b2f8595d3a7b6d6c9548f7da3e27b (diff) | |
download | wireshark-943be4b755d46fa348bea3474af503c3b9f6dc39.tar.gz |
Treat invalid (negative or too-large) values in the packet header as errors.
Change-Id: I86564c485aacd3fcba3f3d8d9da492e0100155e8
Reviewed-on: https://code.wireshark.org/review/12299
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap/iseries.c')
-rw-r--r-- | wiretap/iseries.c | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/wiretap/iseries.c b/wiretap/iseries.c index 4fb1bab118..bb7e9c9d0e 100644 --- a/wiretap/iseries.c +++ b/wiretap/iseries.c @@ -588,8 +588,68 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr, "%12s%*[ \n\t]%12s%*[ \n\t]ETHV2%*[ \n\t]TYPE:%*[ \n\t]%4s", &pktnum, direction, &pkt_len, &hr, &min, &sec, csec, destmac, srcmac, type); - if ((num_items_scanned == 10) && (pkt_len >= 0)) + if (num_items_scanned == 10) { + if (pktnum < 0) + { + *err = WTAP_ERR_BAD_FILE; + *err_info = g_strdup ("iseries: packet header has a negative packet number"); + return FALSE; + } + + if (pkt_len < 0) + { + *err = WTAP_ERR_BAD_FILE; + *err_info = g_strdup ("iseries: packet header has a negative packet length"); + return FALSE; + } + + if (hr < 0) + { + *err = WTAP_ERR_BAD_FILE; + *err_info = g_strdup ("iseries: packet header has a negative hour in the time stamp"); + return FALSE; + } + + if (hr > 23) + { + *err = WTAP_ERR_BAD_FILE; + *err_info = g_strdup ("iseries: packet header has a hour in the time stamp greater than 23"); + return FALSE; + } + + if (min < 0) + { + *err = WTAP_ERR_BAD_FILE; + *err_info = g_strdup ("iseries: packet header has a negative minute in the time stamp"); + return FALSE; + } + + if (min > 59) + { + *err = WTAP_ERR_BAD_FILE; + *err_info = g_strdup ("iseries: packet header has a minute in the time stamp greater than 59"); + return FALSE; + } + + if (sec < 0) + { + *err = WTAP_ERR_BAD_FILE; + *err_info = g_strdup ("iseries: packet header has a negative second in the time stamp"); + return FALSE; + } + + /* + * Yes, 60, even though the time-conversion routines on most OSes + * might not handle leap seconds. + */ + if (sec > 60) + { + *err = WTAP_ERR_BAD_FILE; + *err_info = g_strdup ("iseries: packet header has a second in the time stamp greater than 60"); + return FALSE; + } + /* OK! We found the packet header line */ isValid = TRUE; /* |