Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added exception for x86 & hardware that allows improper ptrs

...

Code Block
bgColor#ccccff
langc
#include <string.h>
 
struct foo_header {
  int len;
  /* ... */
};
  
void func(char *data, size_t offset) {
  struct foo_header header; 
  memcpy(&header, data + offset, sizeof(header));

  /* ... */
}

Exceptions

 

EXP36-EX0: Some platforms, notably x86, have relaxed requirements with regard to pointer alignment. Using a pointer that is not properly aligned is correctly handled by the platform, although the platform may impose a performance penalty. On such a platform, improper pointer alignment is permitted, as it is an efficiency problem but not a security problem.

Risk Assessment

Accessing a pointer or an object that is not properly aligned can cause a program to crash or give wrong information, or it can cause slow pointer accesses (if the architecture allows misaligned accesses).

...