]> The Tcpdump Group git mirrors - libpcap/blobdiff - pcap-common.h
Do all shifts in SWAPSHORT() and SWAPLONG() on unsigned values.
[libpcap] / pcap-common.h
index 88c057cb498702d1d3c7a486a093bc6aeabb6287..8795a8297a64499411397638791aa35417bd7851 100644 (file)
  * machine (if the file was written in little-end order).
  */
 #define        SWAPLONG(y) \
-((((y)&0xff)<<24) | (((y)&0xff00)<<8) | (((y)&0xff0000)>>8) | (((y)>>24)&0xff))
+    (((((u_int)(y))&0xff)<<24) | \
+     ((((u_int)(y))&0xff00)<<8) | \
+     ((((u_int)(y))&0xff0000)>>8) | \
+     ((((u_int)(y))>>24)&0xff))
 #define        SWAPSHORT(y) \
-       ( (((y)&0xff)<<8) | ((u_short)((y)&0xff00)>>8) )
+     ((u_short)(((((u_int)(y))&0xff)<<8) | \
+                ((((u_int)(y))&0xff00)>>8)))
 
 extern int dlt_to_linktype(int dlt);