This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/57862] invalid read struct uint32_t member (ARMV5)


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]