diff options
| author | jvoisin | 2023-08-21 17:46:03 +0200 |
|---|---|---|
| committer | jvoisin | 2023-08-21 17:48:29 +0200 |
| commit | cceaaa8161eb8b0b39854215417b39a9703b7aa5 (patch) | |
| tree | 8a9fa4b7179b2955fcbc5a9e699ffc250f8a023e /include | |
| parent | 5a387cee873365069ad40201fa4d1c514476aa55 (diff) | |
Harden umask
Diffstat (limited to 'include')
| -rw-r--r-- | include/sys/stat.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/include/sys/stat.h b/include/sys/stat.h new file mode 100644 index 0000000..2de34db --- /dev/null +++ b/include/sys/stat.h | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org> | ||
| 3 | * Copyright (C) 2022 q66 <q66@chimera-linux.org> | ||
| 4 | * | ||
| 5 | * Permission to use, copy, modify, and/or distribute this software for any | ||
| 6 | * purpose with or without fee is hereby granted. | ||
| 7 | * | ||
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #ifndef _FORTIFY_SYS_STAT_H | ||
| 18 | #define _FORTIFY_SYS_STAT_H | ||
| 19 | |||
| 20 | #if !defined(__cplusplus) && !defined(__clang__) | ||
| 21 | __extension__ | ||
| 22 | #endif | ||
| 23 | #include_next <sys/stat.h> | ||
| 24 | |||
| 25 | #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 | ||
| 26 | #include "../fortify-headers.h" | ||
| 27 | |||
| 28 | #ifdef __cplusplus | ||
| 29 | extern "C" { | ||
| 30 | #endif | ||
| 31 | |||
| 32 | #if !defined(__clang__) /* FIXME */ | ||
| 33 | #undef umask | ||
| 34 | |||
| 35 | __error_if(__m & ~0777, "'umask' called with invalid mode") | ||
| 36 | _FORTIFY_FN(umask) mode_t umask(mode_t __m) | ||
| 37 | { | ||
| 38 | return __orig_umask(__m); | ||
| 39 | } | ||
| 40 | #endif | ||
| 41 | |||
| 42 | #ifdef __cplusplus | ||
| 43 | } | ||
| 44 | #endif | ||
| 45 | |||
| 46 | #endif | ||
| 47 | |||
| 48 | #endif | ||
