summaryrefslogtreecommitdiffstats
path: root/libc
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2015-04-18 13:04:19 -0400
committerDaniel Micay <danielmicay@gmail.com>2015-04-20 17:31:24 -0400
commit3244d9f07fda946d62afdfa61ed5a876d380d0ff (patch)
treec7f124de4880d6a79e89373b2ee97fa190a71e10 /libc
parentaf7538b49625f1c1c82e984610f26729a18d56bf (diff)
downloadbionic-3244d9f07fda946d62afdfa61ed5a876d380d0ff.zip
bionic-3244d9f07fda946d62afdfa61ed5a876d380d0ff.tar.gz
bionic-3244d9f07fda946d62afdfa61ed5a876d380d0ff.tar.bz2
add a fortified implementation of realpath
Change-Id: Icc59eacd1684f7cddd83d7a2b57dad0c7ada5eb7
Diffstat (limited to 'libc')
-rw-r--r--libc/include/stdlib.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h
index 84bf56d..efca577 100644
--- a/libc/include/stdlib.h
+++ b/libc/include/stdlib.h
@@ -176,6 +176,27 @@ extern size_t __ctype_get_mb_cur_max(void);
#include <android/legacy_stdlib_inlines.h>
#endif
+#if defined(__BIONIC_FORTIFY)
+
+extern char* __realpath_real(const char*, char*) __RENAME(realpath);
+__errordecl(__realpath_size_error, "realpath output parameter must be NULL or a >= PATH_MAX bytes buffer");
+
+#if !defined(__clang__)
+__BIONIC_FORTIFY_INLINE
+char* realpath(const char* path, char* resolved) {
+ size_t bos = __bos(resolved);
+
+ /* PATH_MAX is unavailable without polluting the namespace, but it's always 4096 on Linux */
+ if (bos != __BIONIC_FORTIFY_UNKNOWN_SIZE && bos < 4096) {
+ __realpath_size_error();
+ }
+
+ return __realpath_real(path, resolved);
+}
+#endif
+
+#endif /* defined(__BIONIC_FORTIFY) */
+
__END_DECLS
#endif /* _STDLIB_H */