commit a51406af124e712bc943b29c73fdf219e003ffaa
parent a255506ca487250255f9f048e61cf90166ceab77
Author: sin <sin@2f30.org>
Date: Wed, 15 Jul 2015 16:05:52 +0100
Fix confstr() check
Do not crash unless the overflow would actually happen.
Diffstat:
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/include/unistd.h b/include/unistd.h
@@ -41,10 +41,11 @@ extern "C" {
_FORTIFY_FN(confstr) size_t confstr(int __n, char *__s, size_t __l)
{
size_t __b = __builtin_object_size(__s, 0);
+ size_t __r = __orig_confstr(__n, __s, __b > __l ? __l : __b);
- if (__l > __b)
+ if (__l > __b && __r > __b)
__builtin_trap();
- return __orig_confstr(__n, __s, __l);
+ return __r;
}
_FORTIFY_FN(getcwd) char *getcwd(char *__s, size_t __l)