summaryrefslogtreecommitdiff
path: root/wiretap/csids.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2012-04-19 23:19:10 +0000
committerGuy Harris <guy@alum.mit.edu>2012-04-19 23:19:10 +0000
commit13592b9b577a6fa83571dfb34f2c9c69611ee7a0 (patch)
treee7747e4ad5e1918c3a0119e29b185c556e6a7147 /wiretap/csids.c
parentd8389b542964723f2c1f92d2b04909753857c1be (diff)
downloadwireshark-13592b9b577a6fa83571dfb34f2c9c69611ee7a0.tar.gz
Don't byte-swap bytes that aren't there.
svn path=/trunk/; revision=42144
Diffstat (limited to 'wiretap/csids.c')
-rw-r--r--wiretap/csids.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/wiretap/csids.c b/wiretap/csids.c
index fb05e34b35..53a8013a1a 100644
--- a/wiretap/csids.c
+++ b/wiretap/csids.c
@@ -194,9 +194,14 @@ static gboolean csids_read(wtap *wth, int *err, gchar **err_info,
wth->phdr.ts.nsecs = 0;
if( csids->byteswapped ) {
- PBSWAP16(buf); /* the ip len */
- PBSWAP16(buf+2); /* ip id */
- PBSWAP16(buf+4); /* ip flags and fragoff */
+ if( hdr.caplen >= 2 ) {
+ PBSWAP16(buf); /* the ip len */
+ if( hdr.caplen >= 4 ) {
+ PBSWAP16(buf+2); /* ip id */
+ if( hdr.caplen >= 6 )
+ PBSWAP16(buf+4); /* ip flags and fragoff */
+ }
+ }
}
return TRUE;
@@ -247,9 +252,14 @@ csids_seek_read (wtap *wth,
}
if( csids->byteswapped ) {
- PBSWAP16(pd); /* the ip len */
- PBSWAP16(pd+2); /* ip id */
- PBSWAP16(pd+4); /* ip flags and fragoff */
+ if( hdr.caplen >= 2 ) {
+ PBSWAP16(pd); /* the ip len */
+ if( hdr.caplen >= 4 ) {
+ PBSWAP16(pd+2); /* ip id */
+ if( hdr.caplen >= 6 )
+ PBSWAP16(pd+4); /* ip flags and fragoff */
+ }
+ }
}
return TRUE;