aboutsummaryrefslogtreecommitdiffstats
path: root/libc/include/fcntl.h
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2013-06-17 14:49:19 -0700
committerNick Kralevich <nnk@google.com>2013-06-18 12:14:20 -0700
commit16d1af167f8e36a9aa4a07ae77034ad519b00463 (patch)
tree61abe872a5f2ebebc4fe15205a77158bc8372ec2 /libc/include/fcntl.h
parentb24c0637d06fe0980b9e13a8d0c3e6f4dbda9cd5 (diff)
downloadandroid_bionic-16d1af167f8e36a9aa4a07ae77034ad519b00463.tar.gz
android_bionic-16d1af167f8e36a9aa4a07ae77034ad519b00463.tar.bz2
android_bionic-16d1af167f8e36a9aa4a07ae77034ad519b00463.zip
libc: add limited FORTIFY_SOURCE support for clang
In 829c089f83ddee37203b52bcb294867a9ae7bdbc, we disabled all FORTIFY_SOURCE support when compiling under clang. At the time, we didn't have proper test cases, and couldn't easily create targeted clang tests. This change re-enables FORTIFY_SOURCE support under clang for a limited set of functions, where we have explicit unittests available. The functions are: * memcpy * memmove * strcpy * strncpy * strcat * strncat * memset * strlen (with modifications) * strchr (with modifications) * strrchr (with modifications) It may be possible, in the future, to enable other functions. However, I need to write unittests first. For strlen, strchr, and strrchr, clang unconditionally calls the fortified version of the relevant function. If it doesn't know the size of the buffer it's dealing with, it passes in ((size_t) -1), which is the largest possible size_t. I added two new clang specific unittest files, primarily copied from fortify?_test.cpp. I've also rebuild the entire system with these changes, and didn't observe any obvious problems. Change-Id: If12a15089bb0ffe93824b485290d05b14355fcaa
Diffstat (limited to 'libc/include/fcntl.h')
-rw-r--r--libc/include/fcntl.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/libc/include/fcntl.h b/libc/include/fcntl.h
index 67fd59712..94322fd71 100644
--- a/libc/include/fcntl.h
+++ b/libc/include/fcntl.h
@@ -49,7 +49,7 @@ extern int unlinkat(int dirfd, const char *pathname, int flags);
extern int fcntl(int fd, int command, ...);
extern int creat(const char* path, mode_t mode);
-#if defined(__BIONIC_FORTIFY)
+#if defined(__BIONIC_FORTIFY) && !defined(__clang__)
__errordecl(__creat_error, "called with O_CREAT, but missing mode");
__errordecl(__too_many_args_error, "too many arguments");
extern int __open_real(const char *pathname, int flags, ...)
@@ -98,7 +98,7 @@ int openat(int dirfd, const char *pathname, int flags, ...) {
return __openat_real(dirfd, pathname, flags, __builtin_va_arg_pack());
}
-#endif /* defined(__BIONIC_FORTIFY) */
+#endif /* defined(__BIONIC_FORTIFY) && !defined(__clang__) */
__END_DECLS