diff options
author | Yu Shan <shanyu@google.com> | 2018-09-13 12:01:53 -0700 |
---|---|---|
committer | Yu Shan <shanyu@google.com> | 2018-09-13 12:01:53 -0700 |
commit | 31b7ba975b55c1ad082c74b02ef8b25701035640 (patch) | |
tree | 6e60f0e43bef153ba94a22bc3bd1f1f6d86befd3 /include/keymaster | |
parent | 33fa94bb65fb6202e466355c5595a8317c51cc94 (diff) | |
download | android_system_keymaster-31b7ba975b55c1ad082c74b02ef8b25701035640.tar.gz android_system_keymaster-31b7ba975b55c1ad082c74b02ef8b25701035640.tar.bz2 android_system_keymaster-31b7ba975b55c1ad082c74b02ef8b25701035640.zip |
Remove fortify level for memset.
In memset_s, we intentionally turn off the optimization for memset,
this would cause the checking code in bits/string3.h incorrectly
triggered no matter what size we give to memset. The dead code
which should be optimized away would not, and the code would always
throw an error. To fix this problem, we disable the checking
while including string.h, so that string3.h would not be included
because the checking is only intended to work for optimizatized
code.
Tests: Compile the code using gcc 4.8 and define __FORTIFY_SOURCE
to 2, no error is thrown. Note that gcc after 5 would not throw
an error, instead, compiler would give an warning.
Bug: None
Diffstat (limited to 'include/keymaster')
-rw-r--r-- | include/keymaster/android_keymaster_utils.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/keymaster/android_keymaster_utils.h b/include/keymaster/android_keymaster_utils.h index e33122d..e221ec8 100644 --- a/include/keymaster/android_keymaster_utils.h +++ b/include/keymaster/android_keymaster_utils.h @@ -18,7 +18,17 @@ #define SYSTEM_KEYMASTER_ANDROID_KEYMASTER_UTILS_H_ #include <stdint.h> +#ifndef __clang__ +// We need to diable foritfy level for memset in gcc because we want to use +// memset unoptimized. This would falsely trigger __warn_memset_zero_len in +// /usr/include/bits/string3.h. The inline checking function is only supposed to +// work when the optimization level is at least 1. +#pragma push_macro("__USE_FORTIFY_LEVEL") +#endif #include <string.h> +#ifndef __clang__ +#pragma pop_macro("__USE_FORTIFY_LEVEL") +#endif #include <time.h> // for time_t. #include <keymaster/UniquePtr.h> |