Wireshark mailing list archives

Re: Familiar with gtk/sctp_graph_dlg.c?


From: Michael Tüxen <Michael.Tuexen () lurchi franken de>
Date: Tue, 26 Apr 2011 10:12:39 +0200

On Apr 26, 2011, at 6:23 AM, Guy Harris wrote:


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!
The fields in the packet are 4 byte aligned. But if the whole structure might not...
So should we copy them?

Best regards
Michael

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


___________________________________________________________________________
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: