Wireshark mailing list archives

Re: Familiar with gtk/sctp_graph_dlg.c?


From: Guy Harris <guy () alum mit edu>
Date: Mon, 25 Apr 2011 21:23:22 -0700


On Apr 25, 2011, at 3:01 PM, Michael Tüxen wrote:

dup_list = (guint32 *)((char *)sack_header + 16 + (nr * sizeof(struct gaps)))

Clang likes something that doesn't involve casting a "char *", which is not guaranteed to contain an address that's 
4-byte aligned, to a "guint32 *", which is a pointer that's supposed to be 4-byte aligned...

...and that, on at least some architectures, *MUST* be 4-byte aligned in order for dereferences of it to work!

One such architecture is SPARC, which traps on unaligned references.  I think at least some versions of ARM are other 
such architectures; I don't think it traps on unaligned accesses,  but it might, for example, just act as if the lower 
2 bits of the address are 0.

Unless sack_header is *guaranteed* to be aligned on a 4-byte boundary, that code is unsafe.
___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives:    http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request () wireshark org?subject=unsubscribe


Current thread: