hostap/src/common
Nick Kralevich d447cd596f Updates for stricter automatic memcpy bounds checking
Both Android's libc and glibc support _FORTIFY_SOURCE, a compiler
and libc feature which inserts automatic bounds checking into
common C functions such as memcpy() and strcpy(). If a buffer
overflow occurs when calling a hardened libc function, the
automatic bounds checking will safely shutdown the program and
prevent memory corruption.

Android is experimenting with _FORTIFY_SOURCE=3, a new fortify
level which enhances memcpy() to prevent overflowing an element
of a struct. Under the enhancements, code such as

  struct foo {
    char empty[0];
    char one[1];
    char a[10];
    char b[10];
  };

  int main() {
    foo myfoo;
    int n = atoi("11");
    memcpy(myfoo.a, "01234567890123456789", n);
    return 0;
  }

will cleanly crash when the memcpy() call is made.

Fixup hostap code to support the new level. Specifically:

* Fixup sha1_transform so it works with the enhanced bounds checking.
The old memcpy() code was attempting to write to context.h0, but that
structure element is too small and the write was extending (by design)
into h1, h2, h3, and h4. Use explicit assignments instead of
overflowing the struct element.

* Modify most of the structures in ieee802_11_defs.h to use ISO C99
flexible array members (https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html)
instead of a zero length array. Zero length arrays have zero length,
and any attempt to call memcpy() on such elements will always overflow.
Flexible array members have no such limitation. The only element not
adjusted is probe_req, since doing so will generate a compile time error,
and it's not obvious to me how to fix it.

Signed-off-by: Nick Kralevich <nnk@google.com>
2015-04-13 14:01:40 +03:00
..
common_module_tests.c tests: Add module tests for src/common 2014-05-28 00:56:13 +03:00
defs.h Allow PSK/passphrase to be set only when needed 2015-03-28 11:05:13 +02:00
eapol_common.h MACsec: Add common IEEE 802.1X definitions 2014-05-09 20:05:28 +03:00
gas.c Add generic GAS request mechanism 2012-08-27 18:13:10 +03:00
gas.h Add generic GAS request mechanism 2012-08-27 18:13:10 +03:00
hw_features_common.c Extend offloaded ACS QCA vendor command to support VHT 2015-03-23 12:18:05 +02:00
hw_features_common.h Make hostapd_set_freq_params() common 2015-02-21 16:07:53 +02:00
ieee802_1x_defs.h MACsec: Add common IEEE 802.1X definitions 2014-05-09 20:05:28 +03:00
ieee802_11_common.c DFS offload: Add main DFS handler for offloaded case 2015-03-05 17:21:30 +02:00
ieee802_11_common.h DFS offload: Add main DFS handler for offloaded case 2015-03-05 17:21:30 +02:00
ieee802_11_defs.h Updates for stricter automatic memcpy bounds checking 2015-04-13 14:01:40 +03:00
Makefile Add CONFIG_CODE_COVERAGE=y option for gcov 2013-11-24 19:16:12 +02:00
privsep_commands.h privsep: Fix compilation due to associate() parameter updates 2014-12-25 16:37:12 +02:00
qca-vendor-attr.h Make qca-vendor.h independent of other header files 2014-04-25 11:41:36 +03:00
qca-vendor.h Extend offloaded ACS QCA vendor command to support VHT 2015-03-23 12:18:05 +02:00
sae.c SAE: Clear keys from memory on disassociation 2014-12-29 20:00:02 +02:00
sae.h SAE: Implement retransmission timer 2015-01-10 17:35:52 +02:00
tnc.h tests: TNC testing 2014-05-17 20:05:55 +03:00
version.h The master branch is now used for v2.5 development 2015-03-15 19:38:15 +02:00
wpa_common.c Show OSEN key management properly in scan results 2015-03-25 16:04:03 +02:00
wpa_common.h Add Suite B 192-bit AKM 2015-01-27 01:43:52 +02:00
wpa_ctrl.c Android: wpa_ctrl missing include for sys/stat.h 2015-04-03 10:47:36 +03:00
wpa_ctrl.h Add a AP mode event message for possible PSK/passphrase mismatch 2015-03-19 13:14:21 +02:00
wpa_helpers.c Add wpa_ctrl helper functions for upper level functionality 2014-03-12 01:09:21 +02:00
wpa_helpers.h Add wpa_ctrl helper functions for upper level functionality 2014-03-12 01:09:21 +02:00