summaryrefslogtreecommitdiff
path: root/wiretap/csids.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2007-05-28 06:47:50 +0000
committerGuy Harris <guy@alum.mit.edu>2007-05-28 06:47:50 +0000
commite49fe5baec7fc654cb9e745f25bc21e94b3b69d7 (patch)
treec10c180e108705b62619bf05558db6427c69c72e /wiretap/csids.c
parent430a1de0c0e40cfefb27fcdf3d81f4dfa5501add (diff)
downloadwireshark-e49fe5baec7fc654cb9e745f25bc21e94b3b69d7.tar.gz
Change the Wiretap code so that it doesn't dereference
possibly-unaligned pointers, and turn on -Wcast-align so at least some future code that does that will fail to compile. svn path=/trunk/; revision=21968
Diffstat (limited to 'wiretap/csids.c')
-rw-r--r--wiretap/csids.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/wiretap/csids.c b/wiretap/csids.c
index fc078c2129..1e0f862aa9 100644
--- a/wiretap/csids.c
+++ b/wiretap/csids.c
@@ -184,14 +184,10 @@ static gboolean csids_read(wtap *wth, int *err, gchar **err_info _U_,
wth->phdr.ts.secs = hdr.seconds;
wth->phdr.ts.nsecs = 0;
- if( wth->capture.csids->byteswapped == TRUE ) {
- guint16* swap = (guint16*)buf;
- swap++;
- *(swap) = BSWAP16(*swap); /* the ip len */
- swap++;
- *(swap) = BSWAP16(*swap); /* ip id */
- swap++;
- *(swap) = BSWAP16(*swap); /* ip flags and fragoff */
+ if( wth->capture.csids->byteswapped ) {
+ PBSWAP16(buf); /* the ip len */
+ PBSWAP16(buf+2); /* ip id */
+ PBSWAP16(buf+4); /* ip flags and fragoff */
}
return TRUE;
@@ -240,14 +236,10 @@ csids_seek_read (wtap *wth,
return FALSE;
}
- if( wth->capture.csids->byteswapped == TRUE ) {
- guint16* swap = (guint16*)pd;
- swap++;
- *(swap) = BSWAP16(*swap); /* the ip len */
- swap++;
- *(swap) = BSWAP16(*swap); /* ip id */
- swap++;
- *(swap) = BSWAP16(*swap); /* ip flags and fragoff */
+ if( wth->capture.csids->byteswapped ) {
+ PBSWAP16(pd); /* the ip len */
+ PBSWAP16(pd+2); /* ip id */
+ PBSWAP16(pd+4); /* ip flags and fragoff */
}
return TRUE;