diff options
| author | sin | 2015-07-15 16:05:52 +0100 |
|---|---|---|
| committer | sin | 2015-07-15 16:05:52 +0100 |
| commit | a51406af124e712bc943b29c73fdf219e003ffaa (patch) | |
| tree | bb508b6c46447c56583755a520e047d2b9fd4c0c /include/unistd.h | |
| parent | a255506ca487250255f9f048e61cf90166ceab77 (diff) | |
Fix confstr() check
Do not crash unless the overflow would actually happen.
Diffstat (limited to 'include/unistd.h')
| -rw-r--r-- | include/unistd.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/include/unistd.h b/include/unistd.h index 5fa3b44..b8251ba 100644 --- a/include/unistd.h +++ b/include/unistd.h | |||
| @@ -41,10 +41,11 @@ extern "C" { | |||
| 41 | _FORTIFY_FN(confstr) size_t confstr(int __n, char *__s, size_t __l) | 41 | _FORTIFY_FN(confstr) size_t confstr(int __n, char *__s, size_t __l) |
| 42 | { | 42 | { |
| 43 | size_t __b = __builtin_object_size(__s, 0); | 43 | size_t __b = __builtin_object_size(__s, 0); |
| 44 | size_t __r = __orig_confstr(__n, __s, __b > __l ? __l : __b); | ||
| 44 | 45 | ||
| 45 | if (__l > __b) | 46 | if (__l > __b && __r > __b) |
| 46 | __builtin_trap(); | 47 | __builtin_trap(); |
| 47 | return __orig_confstr(__n, __s, __l); | 48 | return __r; |
| 48 | } | 49 | } |
| 49 | 50 | ||
| 50 | _FORTIFY_FN(getcwd) char *getcwd(char *__s, size_t __l) | 51 | _FORTIFY_FN(getcwd) char *getcwd(char *__s, size_t __l) |
