Wireshark-dev: Re: [Wireshark-dev] Familiar with gtk/sctp_graph_dlg.c?

From: Christopher Maynard <Christopher.Maynard@xxxxxxxxx>
Date: Tue, 26 Apr 2011 12:01:57 +0000 (UTC)
Michael Tüxen <Michael.Tuexen@...> writes:

> >> 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?

Would something like this [untested code] help?

dup_list = (guint32 *)sack_header + (sizeof(struct sack_chunk_header) -
sizeof(struct gaps) + (nr * sizeof(struct gaps)) / sizeof(guint32);