This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/57862] invalid read struct uint32_t member (ARMV5)
- From: "mikpe at it dot uu.se" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 10 Jul 2013 10:31:53 +0000
- Subject: [Bug c/57862] invalid read struct uint32_t member (ARMV5)
- Auto-submitted: auto-generated
- References: <bug-57862-4 at http dot gcc dot gnu dot org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57862
--- Comment #5 from Mikael Pettersson <mikpe at it dot uu.se> ---
Your test case contains this:
===snip===
struct iphdr
{
...
};
...
int main()
{
char thePacket[1518];
memset(thePacket, 0, 1518);
thePacket[30] = 1;
thePacket[31] = 2;
thePacket[32] = 3;
thePacket[33] = 4;
struct ether_header* theEthHeader = (struct ether_header*)(thePacket);
struct iphdr* theIpHeader = (struct iphdr*)((const unsigned
char*)(theEthHeader) + 14);
struct in_addr myInAddr;
myInAddr.s_addr = theIpHeader->daddr;
===snip===
The alignment of thePacket is arbitrary, so the alignment of theIpHeader is
unknown, and struct iphdr is not declared with attribute packed. The final
load may therefore be misaligned.