diff options
| -rw-r--r-- | include/fortify-headers.h | 25 | ||||
| -rw-r--r-- | include/poll.h | 7 | ||||
| -rw-r--r-- | include/stdio.h | 37 | ||||
| -rw-r--r-- | include/stdlib.h | 4 | ||||
| -rw-r--r-- | include/string.h | 33 | ||||
| -rw-r--r-- | include/strings.h | 6 | ||||
| -rw-r--r-- | include/sys/select.h | 13 | ||||
| -rw-r--r-- | include/sys/socket.h | 13 | ||||
| -rw-r--r-- | include/unistd.h | 30 | ||||
| -rw-r--r-- | include/wchar.h | 50 |
10 files changed, 157 insertions, 61 deletions
diff --git a/include/fortify-headers.h b/include/fortify-headers.h index 5a3c6e5..42c8317 100644 --- a/include/fortify-headers.h +++ b/include/fortify-headers.h | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org> | 2 | * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org> |
| 3 | * Copyright (C) 2022 q66 <q66@chimera-linux.org> | ||
| 3 | * | 4 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any | 5 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted. | 6 | * purpose with or without fee is hereby granted. |
| @@ -16,10 +17,30 @@ | |||
| 16 | #ifndef _FORTIFY_HEADERS_H | 17 | #ifndef _FORTIFY_HEADERS_H |
| 17 | #define _FORTIFY_HEADERS_H | 18 | #define _FORTIFY_HEADERS_H |
| 18 | 19 | ||
| 20 | #ifdef __clang__ | ||
| 21 | |||
| 22 | /* clang uses overloads; see https://github.com/llvm/llvm-project/issues/53516 */ | ||
| 23 | #define _FORTIFY_POSN(n) const __attribute__((__pass_object_size__(n))) | ||
| 24 | /* we can't use extern inline with overloads without making them external */ | ||
| 25 | #define _FORTIFY_INLINE static __inline__ \ | ||
| 26 | __attribute__((__always_inline__,__artificial__,__overloadable__)) | ||
| 27 | |||
| 28 | #else /* !__clang__ */ | ||
| 29 | |||
| 30 | #define _FORTIFY_POSN(n) | ||
| 31 | #define _FORTIFY_INLINE extern __inline__ \ | ||
| 32 | __attribute__((__always_inline__,__gnu_inline__,__artificial__)) | ||
| 33 | |||
| 34 | #endif /* __clang__ */ | ||
| 35 | |||
| 36 | #define _FORTIFY_POS0 _FORTIFY_POSN(0) | ||
| 37 | #define _FORTIFY_POS1 _FORTIFY_POSN(1) | ||
| 38 | #define _FORTIFY_POS2 _FORTIFY_POSN(2) | ||
| 39 | |||
| 19 | #define _FORTIFY_STR(s) #s | 40 | #define _FORTIFY_STR(s) #s |
| 20 | #define _FORTIFY_ORIG(p,fn) __typeof__(fn) __orig_##fn __asm__(_FORTIFY_STR(p) #fn) | 41 | #define _FORTIFY_ORIG(p,fn) __typeof__(fn) __orig_##fn __asm__(_FORTIFY_STR(p) #fn) |
| 21 | #define _FORTIFY_FN(fn) _FORTIFY_ORIG(__USER_LABEL_PREFIX__,fn); \ | 42 | #define _FORTIFY_FNB(fn) _FORTIFY_ORIG(__USER_LABEL_PREFIX__,fn) |
| 22 | extern __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__)) | 43 | #define _FORTIFY_FN(fn) _FORTIFY_FNB(fn); _FORTIFY_INLINE |
| 23 | 44 | ||
| 24 | 45 | ||
| 25 | /* Use __builtin_dynamic_object_size with _FORTIFY_SOURCE>2, if available. */ | 46 | /* Use __builtin_dynamic_object_size with _FORTIFY_SOURCE>2, if available. */ |
diff --git a/include/poll.h b/include/poll.h index e89b4e7..8e8de6c 100644 --- a/include/poll.h +++ b/include/poll.h | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org> | 2 | * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org> |
| 3 | * Copyright (C) 2022 q66 <q66@chimera-linux.org> | ||
| 3 | * | 4 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any | 5 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted. | 6 | * purpose with or without fee is hereby granted. |
| @@ -30,7 +31,7 @@ extern "C" { | |||
| 30 | 31 | ||
| 31 | #undef poll | 32 | #undef poll |
| 32 | 33 | ||
| 33 | _FORTIFY_FN(poll) int poll(struct pollfd *__f, nfds_t __n, int __s) | 34 | _FORTIFY_FN(poll) int poll(struct pollfd * _FORTIFY_POS0 __f, nfds_t __n, int __s) |
| 34 | { | 35 | { |
| 35 | size_t __b = __bos(__f, 0); | 36 | size_t __b = __bos(__f, 0); |
| 36 | 37 | ||
| @@ -41,8 +42,8 @@ _FORTIFY_FN(poll) int poll(struct pollfd *__f, nfds_t __n, int __s) | |||
| 41 | 42 | ||
| 42 | #if defined(_GNU_SOURCE) && !_REDIR_TIME64 | 43 | #if defined(_GNU_SOURCE) && !_REDIR_TIME64 |
| 43 | #undef ppoll | 44 | #undef ppoll |
| 44 | _FORTIFY_FN(ppoll) int ppoll(struct pollfd *__f, nfds_t __n, const struct timespec *__s, | 45 | _FORTIFY_FN(ppoll) int ppoll(struct pollfd * _FORTIFY_POS0 __f, nfds_t __n, |
| 45 | const sigset_t *__m) | 46 | const struct timespec *__s, const sigset_t *__m) |
| 46 | { | 47 | { |
| 47 | size_t __b = __bos(__f, 0); | 48 | size_t __b = __bos(__f, 0); |
| 48 | 49 | ||
diff --git a/include/stdio.h b/include/stdio.h index 5102d24..372fd3e 100644 --- a/include/stdio.h +++ b/include/stdio.h | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org> | 2 | * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org> |
| 3 | * Copyright (C) 2022 q66 <q66@chimera-linux.org> | ||
| 3 | * | 4 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any | 5 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted. | 6 | * purpose with or without fee is hereby granted. |
| @@ -37,7 +38,7 @@ extern "C" { | |||
| 37 | #undef sprintf | 38 | #undef sprintf |
| 38 | 39 | ||
| 39 | __access(write_only, 1, 2) | 40 | __access(write_only, 1, 2) |
| 40 | _FORTIFY_FN(fgets) char *fgets(char *__s, int __n, FILE *__f) | 41 | _FORTIFY_FN(fgets) char *fgets(char * _FORTIFY_POS0 __s, int __n, FILE *__f) |
| 41 | { | 42 | { |
| 42 | size_t __b = __bos(__s, 0); | 43 | size_t __b = __bos(__s, 0); |
| 43 | 44 | ||
| @@ -46,7 +47,8 @@ _FORTIFY_FN(fgets) char *fgets(char *__s, int __n, FILE *__f) | |||
| 46 | return __orig_fgets(__s, __n, __f); | 47 | return __orig_fgets(__s, __n, __f); |
| 47 | } | 48 | } |
| 48 | 49 | ||
| 49 | _FORTIFY_FN(fread) size_t fread(void *__d, size_t __n, size_t __m, FILE *__f) | 50 | _FORTIFY_FN(fread) size_t fread(void * _FORTIFY_POS0 __d, size_t __n, |
| 51 | size_t __m, FILE *__f) | ||
| 50 | { | 52 | { |
| 51 | size_t __b = __bos(__d, 0); | 53 | size_t __b = __bos(__d, 0); |
| 52 | 54 | ||
| @@ -57,7 +59,8 @@ _FORTIFY_FN(fread) size_t fread(void *__d, size_t __n, size_t __m, FILE *__f) | |||
| 57 | return __orig_fread(__d, __n, __m, __f); | 59 | return __orig_fread(__d, __n, __m, __f); |
| 58 | } | 60 | } |
| 59 | 61 | ||
| 60 | _FORTIFY_FN(fwrite) size_t fwrite(const void *__d, size_t __n, size_t __m, FILE *__f) | 62 | _FORTIFY_FN(fwrite) size_t fwrite(const void * _FORTIFY_POS0 __d, size_t __n, |
| 63 | size_t __m, FILE *__f) | ||
| 61 | { | 64 | { |
| 62 | size_t __b = __bos(__d, 0); | 65 | size_t __b = __bos(__d, 0); |
| 63 | 66 | ||
| @@ -68,8 +71,8 @@ _FORTIFY_FN(fwrite) size_t fwrite(const void *__d, size_t __n, size_t __m, FILE | |||
| 68 | return __orig_fwrite(__d, __n, __m, __f); | 71 | return __orig_fwrite(__d, __n, __m, __f); |
| 69 | } | 72 | } |
| 70 | 73 | ||
| 71 | _FORTIFY_FN(vsnprintf) int vsnprintf(char *__s, size_t __n, const char *__f, | 74 | _FORTIFY_FN(vsnprintf) int vsnprintf(char * _FORTIFY_POS0 __s, size_t __n, |
| 72 | __builtin_va_list __v) | 75 | const char *__f, __builtin_va_list __v) |
| 73 | { | 76 | { |
| 74 | size_t __b = __bos(__s, 0); | 77 | size_t __b = __bos(__s, 0); |
| 75 | 78 | ||
| @@ -78,7 +81,8 @@ _FORTIFY_FN(vsnprintf) int vsnprintf(char *__s, size_t __n, const char *__f, | |||
| 78 | return __orig_vsnprintf(__s, __n, __f, __v); | 81 | return __orig_vsnprintf(__s, __n, __f, __v); |
| 79 | } | 82 | } |
| 80 | 83 | ||
| 81 | _FORTIFY_FN(vsprintf) int vsprintf(char *__s, const char *__f, __builtin_va_list __v) | 84 | _FORTIFY_FN(vsprintf) int vsprintf(char * _FORTIFY_POS0 __s, const char *__f, |
| 85 | __builtin_va_list __v) | ||
| 82 | { | 86 | { |
| 83 | size_t __b = __bos(__s, 0); | 87 | size_t __b = __bos(__s, 0); |
| 84 | int __r; | 88 | int __r; |
| @@ -93,7 +97,23 @@ _FORTIFY_FN(vsprintf) int vsprintf(char *__s, const char *__f, __builtin_va_list | |||
| 93 | return __r; | 97 | return __r; |
| 94 | } | 98 | } |
| 95 | 99 | ||
| 96 | _FORTIFY_FN(snprintf) int snprintf(char *__s, size_t __n, const char *__f, ...) | 100 | #if defined(__has_builtin) |
| 101 | #if __has_builtin(__builtin_va_arg_pack) | ||
| 102 | |||
| 103 | /* clang is missing __builtin_va_arg_pack, so we cannot use these impls | ||
| 104 | * outside of gcc; we then have a few options: | ||
| 105 | * | ||
| 106 | * 1) using va_start/end and implementing these functions as static inline, | ||
| 107 | * with inlining never happening; that means extra symbols with internal | ||
| 108 | * linkage, which is not ideal | ||
| 109 | * 2) using macros; this is incompatible with c++ and since musl does not | ||
| 110 | * have the __chk variants, we'd need to implement a body with intermediate | ||
| 111 | * variables within the macro, which means more non-portable mess | ||
| 112 | * 3) not implementing these under clang, which is what we do for now | ||
| 113 | */ | ||
| 114 | |||
| 115 | _FORTIFY_FN(snprintf) int snprintf(char *__s, size_t __n, | ||
| 116 | const char *__f, ...) | ||
| 97 | { | 117 | { |
| 98 | size_t __b = __bos(__s, 0); | 118 | size_t __b = __bos(__s, 0); |
| 99 | 119 | ||
| @@ -117,6 +137,9 @@ _FORTIFY_FN(sprintf) int sprintf(char *__s, const char *__f, ...) | |||
| 117 | return __r; | 137 | return __r; |
| 118 | } | 138 | } |
| 119 | 139 | ||
| 140 | #endif /* __has_builtin(__builtin_va_arg_pack) */ | ||
| 141 | #endif /* defined(__has_builtin) */ | ||
| 142 | |||
| 120 | #ifdef __cplusplus | 143 | #ifdef __cplusplus |
| 121 | } | 144 | } |
| 122 | #endif | 145 | #endif |
diff --git a/include/stdlib.h b/include/stdlib.h index bc93b60..38015d4 100644 --- a/include/stdlib.h +++ b/include/stdlib.h | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org> | 2 | * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org> |
| 3 | * Copyright (C) 2022 q66 <q66@chimera-linux.org> | ||
| 3 | * | 4 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any | 5 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted. | 6 | * purpose with or without fee is hereby granted. |
| @@ -35,7 +36,8 @@ __extension__ | |||
| 35 | extern "C" { | 36 | extern "C" { |
| 36 | #endif | 37 | #endif |
| 37 | 38 | ||
| 38 | #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) | 39 | /* FIXME clang */ |
| 40 | #if (defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)) && !defined(__clang__) | ||
| 39 | #undef realpath | 41 | #undef realpath |
| 40 | _FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r) | 42 | _FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r) |
| 41 | { | 43 | { |
diff --git a/include/string.h b/include/string.h index c9f8839..bbf24fe 100644 --- a/include/string.h +++ b/include/string.h | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org> | 2 | * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org> |
| 3 | * Copyright (C) 2022 q66 <q66@chimera-linux.org> | ||
| 3 | * | 4 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any | 5 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted. | 6 | * purpose with or without fee is hereby granted. |
| @@ -38,7 +39,8 @@ extern "C" { | |||
| 38 | 39 | ||
| 39 | __access(write_only, 1) | 40 | __access(write_only, 1) |
| 40 | __access(read_only, 2, 3) | 41 | __access(read_only, 2, 3) |
| 41 | _FORTIFY_FN(memcpy) void *memcpy(void *__od, const void *__os, size_t __n) | 42 | _FORTIFY_FN(memcpy) void *memcpy(void * _FORTIFY_POS0 __od, |
| 43 | const void * _FORTIFY_POS0 __os, size_t __n) | ||
| 42 | { | 44 | { |
| 43 | size_t __bd = __bos(__od, 0); | 45 | size_t __bd = __bos(__od, 0); |
| 44 | size_t __bs = __bos(__os, 0); | 46 | size_t __bs = __bos(__os, 0); |
| @@ -57,7 +59,8 @@ _FORTIFY_FN(memcpy) void *memcpy(void *__od, const void *__os, size_t __n) | |||
| 57 | 59 | ||
| 58 | __access(write_only, 1) | 60 | __access(write_only, 1) |
| 59 | __access(read_only, 2, 3) | 61 | __access(read_only, 2, 3) |
| 60 | _FORTIFY_FN(memmove) void *memmove(void *__d, const void *__s, size_t __n) | 62 | _FORTIFY_FN(memmove) void *memmove(void * _FORTIFY_POS0 __d, |
| 63 | const void * _FORTIFY_POS0 __s, size_t __n) | ||
| 61 | { | 64 | { |
| 62 | size_t __bd = __bos(__d, 0); | 65 | size_t __bd = __bos(__d, 0); |
| 63 | size_t __bs = __bos(__s, 0); | 66 | size_t __bs = __bos(__s, 0); |
| @@ -68,7 +71,7 @@ _FORTIFY_FN(memmove) void *memmove(void *__d, const void *__s, size_t __n) | |||
| 68 | } | 71 | } |
| 69 | 72 | ||
| 70 | __access(write_only, 1) | 73 | __access(write_only, 1) |
| 71 | _FORTIFY_FN(memset) void *memset(void *__d, int __c, size_t __n) | 74 | _FORTIFY_FN(memset) void *memset(void * _FORTIFY_POS0 __d, int __c, size_t __n) |
| 72 | { | 75 | { |
| 73 | size_t __b = __bos(__d, 0); | 76 | size_t __b = __bos(__d, 0); |
| 74 | 77 | ||
| @@ -83,7 +86,7 @@ _FORTIFY_FN(memset) void *memset(void *__d, int __c, size_t __n) | |||
| 83 | #undef stpcpy | 86 | #undef stpcpy |
| 84 | __access(write_only, 1) | 87 | __access(write_only, 1) |
| 85 | __access(read_only, 2) | 88 | __access(read_only, 2) |
| 86 | _FORTIFY_FN(stpcpy) char *stpcpy(char *__d, const char *__s) | 89 | _FORTIFY_FN(stpcpy) char *stpcpy(char * _FORTIFY_POS0 __d, const char *__s) |
| 87 | { | 90 | { |
| 88 | size_t __n = strlen(__s) + 1; | 91 | size_t __n = strlen(__s) + 1; |
| 89 | 92 | ||
| @@ -102,7 +105,8 @@ _FORTIFY_FN(stpcpy) char *stpcpy(char *__d, const char *__s) | |||
| 102 | #undef stpncpy | 105 | #undef stpncpy |
| 103 | __access(write_only, 1) | 106 | __access(write_only, 1) |
| 104 | __access(read_only, 2, 3) | 107 | __access(read_only, 2, 3) |
| 105 | _FORTIFY_FN(stpncpy) char *stpncpy(char *__d, const char *__s, size_t __n) | 108 | _FORTIFY_FN(stpncpy) char *stpncpy(char * _FORTIFY_POS0 __d, const char *__s, |
| 109 | size_t __n) | ||
| 106 | { | 110 | { |
| 107 | /* trap if pointers are overlapping but not if dst == src. | 111 | /* trap if pointers are overlapping but not if dst == src. |
| 108 | * gcc seems to like to generate code that relies on dst == src */ | 112 | * gcc seems to like to generate code that relies on dst == src */ |
| @@ -119,7 +123,7 @@ _FORTIFY_FN(stpncpy) char *stpncpy(char *__d, const char *__s, size_t __n) | |||
| 119 | 123 | ||
| 120 | __access (read_write, 1) | 124 | __access (read_write, 1) |
| 121 | __access (read_only, 2) | 125 | __access (read_only, 2) |
| 122 | _FORTIFY_FN(strcat) char *strcat(char *__d, const char *__s) | 126 | _FORTIFY_FN(strcat) char *strcat(char * _FORTIFY_POS0 __d, const char *__s) |
| 123 | { | 127 | { |
| 124 | size_t __b = __bos(__d, 0); | 128 | size_t __b = __bos(__d, 0); |
| 125 | 129 | ||
| @@ -130,7 +134,7 @@ _FORTIFY_FN(strcat) char *strcat(char *__d, const char *__s) | |||
| 130 | 134 | ||
| 131 | __access (write_only, 1) | 135 | __access (write_only, 1) |
| 132 | __access (read_only, 2) | 136 | __access (read_only, 2) |
| 133 | _FORTIFY_FN(strcpy) char *strcpy(char *__d, const char *__s) | 137 | _FORTIFY_FN(strcpy) char *strcpy(char * _FORTIFY_POS0 __d, const char *__s) |
| 134 | { | 138 | { |
| 135 | size_t __n = strlen(__s) + 1; | 139 | size_t __n = strlen(__s) + 1; |
| 136 | 140 | ||
| @@ -148,7 +152,8 @@ _FORTIFY_FN(strcpy) char *strcpy(char *__d, const char *__s) | |||
| 148 | 152 | ||
| 149 | __access (read_write, 1) | 153 | __access (read_write, 1) |
| 150 | __access (read_only, 2, 3) | 154 | __access (read_only, 2, 3) |
| 151 | _FORTIFY_FN(strncat) char *strncat(char *__d, const char *__s, size_t __n) | 155 | _FORTIFY_FN(strncat) char *strncat(char * _FORTIFY_POS0 __d, const char *__s, |
| 156 | size_t __n) | ||
| 152 | { | 157 | { |
| 153 | size_t __b = __bos(__d, 0); | 158 | size_t __b = __bos(__d, 0); |
| 154 | 159 | ||
| @@ -165,7 +170,8 @@ _FORTIFY_FN(strncat) char *strncat(char *__d, const char *__s, size_t __n) | |||
| 165 | 170 | ||
| 166 | __access (write_only, 1) | 171 | __access (write_only, 1) |
| 167 | __access (read_only, 2, 3) | 172 | __access (read_only, 2, 3) |
| 168 | _FORTIFY_FN(strncpy) char *strncpy(char *__d, const char *__s, size_t __n) | 173 | _FORTIFY_FN(strncpy) char *strncpy(char * _FORTIFY_POS0 __d, |
| 174 | const char *__s, size_t __n) | ||
| 169 | { | 175 | { |
| 170 | /* trap if pointers are overlapping but not if dst == src. | 176 | /* trap if pointers are overlapping but not if dst == src. |
| 171 | * gcc seems to like to generate code that relies on dst == src */ | 177 | * gcc seems to like to generate code that relies on dst == src */ |
| @@ -183,7 +189,8 @@ _FORTIFY_FN(strncpy) char *strncpy(char *__d, const char *__s, size_t __n) | |||
| 183 | #undef mempcpy | 189 | #undef mempcpy |
| 184 | __access(write_only, 1) | 190 | __access(write_only, 1) |
| 185 | __access(read_only, 2, 3) | 191 | __access(read_only, 2, 3) |
| 186 | _FORTIFY_FN(mempcpy) void *mempcpy(void *__d, const void *__s, size_t __n) | 192 | _FORTIFY_FN(mempcpy) void *mempcpy(void * _FORTIFY_POS0 __d, |
| 193 | const void * _FORTIFY_POS0 __s, size_t __n) | ||
| 187 | { | 194 | { |
| 188 | size_t __bd = __bos(__d, 0); | 195 | size_t __bd = __bos(__d, 0); |
| 189 | size_t __bs = __bos(__s, 0); | 196 | size_t __bs = __bos(__s, 0); |
| @@ -199,7 +206,8 @@ _FORTIFY_FN(mempcpy) void *mempcpy(void *__d, const void *__s, size_t __n) | |||
| 199 | #undef strlcpy | 206 | #undef strlcpy |
| 200 | __access (read_write, 1) | 207 | __access (read_write, 1) |
| 201 | __access (read_only, 2, 3) | 208 | __access (read_only, 2, 3) |
| 202 | _FORTIFY_FN(strlcat) size_t strlcat(char *__d, const char *__s, size_t __n) | 209 | _FORTIFY_FN(strlcat) size_t strlcat(char * _FORTIFY_POS0 __d, |
| 210 | const char *__s, size_t __n) | ||
| 203 | { | 211 | { |
| 204 | size_t __b = __bos(__d, 0); | 212 | size_t __b = __bos(__d, 0); |
| 205 | 213 | ||
| @@ -210,7 +218,8 @@ _FORTIFY_FN(strlcat) size_t strlcat(char *__d, const char *__s, size_t __n) | |||
| 210 | 218 | ||
| 211 | __access (write_only, 1) | 219 | __access (write_only, 1) |
| 212 | __access (read_only, 2, 3) | 220 | __access (read_only, 2, 3) |
| 213 | _FORTIFY_FN(strlcpy) size_t strlcpy(char *__d, const char *__s, size_t __n) | 221 | _FORTIFY_FN(strlcpy) size_t strlcpy(char * _FORTIFY_POS0 __d, |
| 222 | const char *__s, size_t __n) | ||
| 214 | { | 223 | { |
| 215 | size_t __b = __bos(__d, 0); | 224 | size_t __b = __bos(__d, 0); |
| 216 | 225 | ||
diff --git a/include/strings.h b/include/strings.h index 7645848..862b7be 100644 --- a/include/strings.h +++ b/include/strings.h | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org> | 2 | * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org> |
| 3 | * Copyright (C) 2022 q66 <q66@chimera-linux.org> | ||
| 3 | * | 4 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any | 5 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted. | 6 | * purpose with or without fee is hereby granted. |
| @@ -30,7 +31,8 @@ extern "C" { | |||
| 30 | || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700) | 31 | || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700) |
| 31 | #undef bcopy | 32 | #undef bcopy |
| 32 | #undef bzero | 33 | #undef bzero |
| 33 | _FORTIFY_FN(bcopy) void bcopy(const void *__s, void *__d, size_t __n) | 34 | _FORTIFY_FN(bcopy) void bcopy(const void * _FORTIFY_POS0 __s, |
| 35 | void * _FORTIFY_POS0 __d, size_t __n) | ||
| 34 | { | 36 | { |
| 35 | size_t __bd = __bos(__d, 0); | 37 | size_t __bd = __bos(__d, 0); |
| 36 | size_t __bs = __bos(__s, 0); | 38 | size_t __bs = __bos(__s, 0); |
| @@ -40,7 +42,7 @@ _FORTIFY_FN(bcopy) void bcopy(const void *__s, void *__d, size_t __n) | |||
| 40 | return __orig_bcopy(__s, __d, __n); | 42 | return __orig_bcopy(__s, __d, __n); |
| 41 | } | 43 | } |
| 42 | 44 | ||
| 43 | _FORTIFY_FN(bzero) void bzero(void *__s, size_t __n) | 45 | _FORTIFY_FN(bzero) void bzero(void * _FORTIFY_POS0 __s, size_t __n) |
| 44 | { | 46 | { |
| 45 | size_t __b = __bos(__s, 0); | 47 | size_t __b = __bos(__s, 0); |
| 46 | 48 | ||
diff --git a/include/sys/select.h b/include/sys/select.h index 1a5afbe..265c7e1 100644 --- a/include/sys/select.h +++ b/include/sys/select.h | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org> | 2 | * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org> |
| 3 | * Copyright (C) 2022 q66 <q66@chimera-linux.org> | ||
| 3 | * | 4 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any | 5 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted. | 6 | * purpose with or without fee is hereby granted. |
| @@ -27,8 +28,14 @@ __extension__ | |||
| 27 | extern "C" { | 28 | extern "C" { |
| 28 | #endif | 29 | #endif |
| 29 | 30 | ||
| 31 | #ifdef __clang__ | ||
| 32 | #define _FORTIFY_FD_POS0 const __attribute__((__pass_object_size__(0))) | ||
| 33 | #else | ||
| 34 | #define _FORTIFY_FD_POS0 | ||
| 35 | #endif | ||
| 36 | |||
| 30 | static __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__)) | 37 | static __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__)) |
| 31 | void __fortify_FD_CLR(int __f, fd_set *__s) | 38 | void __fortify_FD_CLR(int __f, fd_set * _FORTIFY_FD_POS0 __s) |
| 32 | { | 39 | { |
| 33 | size_t __b = __bos(__s, 0); | 40 | size_t __b = __bos(__s, 0); |
| 34 | 41 | ||
| @@ -38,7 +45,7 @@ void __fortify_FD_CLR(int __f, fd_set *__s) | |||
| 38 | } | 45 | } |
| 39 | 46 | ||
| 40 | static __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__)) | 47 | static __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__)) |
| 41 | void __fortify_FD_SET(int __f, fd_set *__s) | 48 | void __fortify_FD_SET(int __f, fd_set * _FORTIFY_FD_POS0 __s) |
| 42 | { | 49 | { |
| 43 | size_t __b = __bos(__s, 0); | 50 | size_t __b = __bos(__s, 0); |
| 44 | 51 | ||
| @@ -47,6 +54,8 @@ void __fortify_FD_SET(int __f, fd_set *__s) | |||
| 47 | FD_SET(__f, __s); | 54 | FD_SET(__f, __s); |
| 48 | } | 55 | } |
| 49 | 56 | ||
| 57 | #undef _FORTIFY_FD_POS0 | ||
| 58 | |||
| 50 | #undef FD_CLR | 59 | #undef FD_CLR |
| 51 | #define FD_CLR(fd, set) __fortify_FD_CLR(fd, set) | 60 | #define FD_CLR(fd, set) __fortify_FD_CLR(fd, set) |
| 52 | #undef FD_SET | 61 | #undef FD_SET |
diff --git a/include/sys/socket.h b/include/sys/socket.h index 604d65a..7dfa71a 100644 --- a/include/sys/socket.h +++ b/include/sys/socket.h | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org> | 2 | * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org> |
| 3 | * Copyright (C) 2022 q66 <q66@chimera-linux.org> | ||
| 3 | * | 4 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any | 5 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted. | 6 | * purpose with or without fee is hereby granted. |
| @@ -33,7 +34,8 @@ extern "C" { | |||
| 33 | #undef send | 34 | #undef send |
| 34 | #undef sendto | 35 | #undef sendto |
| 35 | 36 | ||
| 36 | _FORTIFY_FN(recv) ssize_t recv(int __f, void *__s, size_t __n, int __fl) | 37 | _FORTIFY_FN(recv) ssize_t recv(int __f, void * _FORTIFY_POS0 __s, size_t __n, |
| 38 | int __fl) | ||
| 37 | { | 39 | { |
| 38 | size_t __b = __bos(__s, 0); | 40 | size_t __b = __bos(__s, 0); |
| 39 | 41 | ||
| @@ -42,7 +44,8 @@ _FORTIFY_FN(recv) ssize_t recv(int __f, void *__s, size_t __n, int __fl) | |||
| 42 | return __orig_recv(__f, __s, __n, __fl); | 44 | return __orig_recv(__f, __s, __n, __fl); |
| 43 | } | 45 | } |
| 44 | 46 | ||
| 45 | _FORTIFY_FN(recvfrom) ssize_t recvfrom(int __f, void *__s, size_t __n, int __fl, | 47 | _FORTIFY_FN(recvfrom) ssize_t recvfrom(int __f, void * _FORTIFY_POS0 __s, |
| 48 | size_t __n, int __fl, | ||
| 46 | struct sockaddr *__a, socklen_t *__l) | 49 | struct sockaddr *__a, socklen_t *__l) |
| 47 | { | 50 | { |
| 48 | size_t __b = __bos(__s, 0); | 51 | size_t __b = __bos(__s, 0); |
| @@ -52,7 +55,8 @@ _FORTIFY_FN(recvfrom) ssize_t recvfrom(int __f, void *__s, size_t __n, int __fl, | |||
| 52 | return __orig_recvfrom(__f, __s, __n, __fl, __a, __l); | 55 | return __orig_recvfrom(__f, __s, __n, __fl, __a, __l); |
| 53 | } | 56 | } |
| 54 | 57 | ||
| 55 | _FORTIFY_FN(send) ssize_t send(int __f, const void *__s, size_t __n, int __fl) | 58 | _FORTIFY_FN(send) ssize_t send(int __f, const void * _FORTIFY_POS0 __s, |
| 59 | size_t __n, int __fl) | ||
| 56 | { | 60 | { |
| 57 | size_t __b = __bos(__s, 0); | 61 | size_t __b = __bos(__s, 0); |
| 58 | 62 | ||
| @@ -61,7 +65,8 @@ _FORTIFY_FN(send) ssize_t send(int __f, const void *__s, size_t __n, int __fl) | |||
| 61 | return __orig_send(__f, __s, __n, __fl); | 65 | return __orig_send(__f, __s, __n, __fl); |
| 62 | } | 66 | } |
| 63 | 67 | ||
| 64 | _FORTIFY_FN(sendto) ssize_t sendto(int __f, const void *__s, size_t __n, int __fl, | 68 | _FORTIFY_FN(sendto) ssize_t sendto(int __f, const void * _FORTIFY_POS0 __s, |
| 69 | size_t __n, int __fl, | ||
| 65 | const struct sockaddr *__a, socklen_t __l) | 70 | const struct sockaddr *__a, socklen_t __l) |
| 66 | { | 71 | { |
| 67 | size_t __b = __bos(__s, 0); | 72 | size_t __b = __bos(__s, 0); |
diff --git a/include/unistd.h b/include/unistd.h index 818adaa..3e5c040 100644 --- a/include/unistd.h +++ b/include/unistd.h | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org> | 2 | * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org> |
| 3 | * Copyright (C) 2022 q66 <q66@chimera-linux.org> | ||
| 3 | * | 4 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any | 5 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted. | 6 | * purpose with or without fee is hereby granted. |
| @@ -40,7 +41,7 @@ extern "C" { | |||
| 40 | #undef ttyname_r | 41 | #undef ttyname_r |
| 41 | #undef write | 42 | #undef write |
| 42 | 43 | ||
| 43 | _FORTIFY_FN(confstr) size_t confstr(int __n, char *__s, size_t __l) | 44 | _FORTIFY_FN(confstr) size_t confstr(int __n, char * _FORTIFY_POS0 __s, size_t __l) |
| 44 | { | 45 | { |
| 45 | size_t __b = __bos(__s, 0); | 46 | size_t __b = __bos(__s, 0); |
| 46 | size_t __r = __orig_confstr(__n, __s, __b > __l ? __l : __b); | 47 | size_t __r = __orig_confstr(__n, __s, __b > __l ? __l : __b); |
| @@ -50,7 +51,7 @@ _FORTIFY_FN(confstr) size_t confstr(int __n, char *__s, size_t __l) | |||
| 50 | return __r; | 51 | return __r; |
| 51 | } | 52 | } |
| 52 | 53 | ||
| 53 | _FORTIFY_FN(getcwd) char *getcwd(char *__s, size_t __l) | 54 | _FORTIFY_FN(getcwd) char *getcwd(char * _FORTIFY_POS0 __s, size_t __l) |
| 54 | { | 55 | { |
| 55 | size_t __b = __bos(__s, 0); | 56 | size_t __b = __bos(__s, 0); |
| 56 | 57 | ||
| @@ -61,7 +62,7 @@ _FORTIFY_FN(getcwd) char *getcwd(char *__s, size_t __l) | |||
| 61 | 62 | ||
| 62 | #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) | 63 | #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) |
| 63 | #undef getdomainname | 64 | #undef getdomainname |
| 64 | _FORTIFY_FN(getdomainname) int getdomainname(char *__s, size_t __l) | 65 | _FORTIFY_FN(getdomainname) int getdomainname(char * _FORTIFY_POS0 __s, size_t __l) |
| 65 | { | 66 | { |
| 66 | size_t __b = __bos(__s, 0); | 67 | size_t __b = __bos(__s, 0); |
| 67 | 68 | ||
| @@ -71,7 +72,7 @@ _FORTIFY_FN(getdomainname) int getdomainname(char *__s, size_t __l) | |||
| 71 | } | 72 | } |
| 72 | #endif | 73 | #endif |
| 73 | 74 | ||
| 74 | _FORTIFY_FN(getgroups) int getgroups(int __l, gid_t *__s) | 75 | _FORTIFY_FN(getgroups) int getgroups(int __l, gid_t * _FORTIFY_POS0 __s) |
| 75 | { | 76 | { |
| 76 | size_t __b = __bos(__s, 0); | 77 | size_t __b = __bos(__s, 0); |
| 77 | 78 | ||
| @@ -80,7 +81,7 @@ _FORTIFY_FN(getgroups) int getgroups(int __l, gid_t *__s) | |||
| 80 | return __orig_getgroups(__l, __s); | 81 | return __orig_getgroups(__l, __s); |
| 81 | } | 82 | } |
| 82 | 83 | ||
| 83 | _FORTIFY_FN(gethostname) int gethostname(char *__s, size_t __l) | 84 | _FORTIFY_FN(gethostname) int gethostname(char * _FORTIFY_POS0 __s, size_t __l) |
| 84 | { | 85 | { |
| 85 | size_t __b = __bos(__s, 0); | 86 | size_t __b = __bos(__s, 0); |
| 86 | 87 | ||
| @@ -89,7 +90,7 @@ _FORTIFY_FN(gethostname) int gethostname(char *__s, size_t __l) | |||
| 89 | return __orig_gethostname(__s, __l); | 90 | return __orig_gethostname(__s, __l); |
| 90 | } | 91 | } |
| 91 | 92 | ||
| 92 | _FORTIFY_FN(getlogin_r) int getlogin_r(char *__s, size_t __l) | 93 | _FORTIFY_FN(getlogin_r) int getlogin_r(char * _FORTIFY_POS0 __s, size_t __l) |
| 93 | { | 94 | { |
| 94 | size_t __b = __bos(__s, 0); | 95 | size_t __b = __bos(__s, 0); |
| 95 | 96 | ||
| @@ -98,7 +99,8 @@ _FORTIFY_FN(getlogin_r) int getlogin_r(char *__s, size_t __l) | |||
| 98 | return __orig_getlogin_r(__s, __l); | 99 | return __orig_getlogin_r(__s, __l); |
| 99 | } | 100 | } |
| 100 | 101 | ||
| 101 | _FORTIFY_FN(pread) ssize_t pread(int __f, void *__s, size_t __n, off_t __o) | 102 | _FORTIFY_FN(pread) ssize_t pread(int __f, void * _FORTIFY_POS0 __s, |
| 103 | size_t __n, off_t __o) | ||
| 102 | { | 104 | { |
| 103 | size_t __b = __bos(__s, 0); | 105 | size_t __b = __bos(__s, 0); |
| 104 | 106 | ||
| @@ -107,7 +109,7 @@ _FORTIFY_FN(pread) ssize_t pread(int __f, void *__s, size_t __n, off_t __o) | |||
| 107 | return __orig_pread(__f, __s, __n, __o); | 109 | return __orig_pread(__f, __s, __n, __o); |
| 108 | } | 110 | } |
| 109 | 111 | ||
| 110 | _FORTIFY_FN(read) ssize_t read(int __f, void *__s, size_t __n) | 112 | _FORTIFY_FN(read) ssize_t read(int __f, void * _FORTIFY_POS0 __s, size_t __n) |
| 111 | { | 113 | { |
| 112 | size_t __b = __bos(__s, 0); | 114 | size_t __b = __bos(__s, 0); |
| 113 | 115 | ||
| @@ -116,7 +118,8 @@ _FORTIFY_FN(read) ssize_t read(int __f, void *__s, size_t __n) | |||
| 116 | return __orig_read(__f, __s, __n); | 118 | return __orig_read(__f, __s, __n); |
| 117 | } | 119 | } |
| 118 | 120 | ||
| 119 | _FORTIFY_FN(readlink) ssize_t readlink(const char *__p, char *__s, size_t __n) | 121 | _FORTIFY_FN(readlink) ssize_t readlink(const char *__p, |
| 122 | char * _FORTIFY_POS0 __s, size_t __n) | ||
| 120 | { | 123 | { |
| 121 | size_t __b = __bos(__s, 0); | 124 | size_t __b = __bos(__s, 0); |
| 122 | 125 | ||
| @@ -125,7 +128,8 @@ _FORTIFY_FN(readlink) ssize_t readlink(const char *__p, char *__s, size_t __n) | |||
| 125 | return __orig_readlink(__p, __s, __n); | 128 | return __orig_readlink(__p, __s, __n); |
| 126 | } | 129 | } |
| 127 | 130 | ||
| 128 | _FORTIFY_FN(readlinkat) ssize_t readlinkat(int __f, const char *__p, char *__s, size_t __n) | 131 | _FORTIFY_FN(readlinkat) ssize_t readlinkat(int __f, const char *__p, |
| 132 | char * _FORTIFY_POS0 __s, size_t __n) | ||
| 129 | { | 133 | { |
| 130 | size_t __b = __bos(__s, 0); | 134 | size_t __b = __bos(__s, 0); |
| 131 | 135 | ||
| @@ -134,7 +138,8 @@ _FORTIFY_FN(readlinkat) ssize_t readlinkat(int __f, const char *__p, char *__s, | |||
| 134 | return __orig_readlinkat(__f, __p, __s, __n); | 138 | return __orig_readlinkat(__f, __p, __s, __n); |
| 135 | } | 139 | } |
| 136 | 140 | ||
| 137 | _FORTIFY_FN(ttyname_r) int ttyname_r(int __f, char *__s, size_t __n) | 141 | _FORTIFY_FN(ttyname_r) int ttyname_r(int __f, char * _FORTIFY_POS0 __s, |
| 142 | size_t __n) | ||
| 138 | { | 143 | { |
| 139 | size_t __b = __bos(__s, 0); | 144 | size_t __b = __bos(__s, 0); |
| 140 | 145 | ||
| @@ -143,7 +148,8 @@ _FORTIFY_FN(ttyname_r) int ttyname_r(int __f, char *__s, size_t __n) | |||
| 143 | return __orig_ttyname_r(__f, __s, __n); | 148 | return __orig_ttyname_r(__f, __s, __n); |
| 144 | } | 149 | } |
| 145 | 150 | ||
| 146 | _FORTIFY_FN(write) ssize_t write(int __f, const void *__s, size_t __n) | 151 | _FORTIFY_FN(write) ssize_t write(int __f, const void * _FORTIFY_POS0 __s, |
| 152 | size_t __n) | ||
| 147 | { | 153 | { |
| 148 | size_t __b = __bos(__s, 0); | 154 | size_t __b = __bos(__s, 0); |
| 149 | 155 | ||
diff --git a/include/wchar.h b/include/wchar.h index 4f25b0c..d031397 100644 --- a/include/wchar.h +++ b/include/wchar.h | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2015-2017 Dimitris Papastamos <sin@2f30.org> | 2 | * Copyright (C) 2015-2017 Dimitris Papastamos <sin@2f30.org> |
| 3 | * Copyright (C) 2022 q66 <q66@chimera-linux.org> | ||
| 3 | * | 4 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any | 5 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted. | 6 | * purpose with or without fee is hereby granted. |
| @@ -55,7 +56,8 @@ extern "C" { | |||
| 55 | #undef wmemmove | 56 | #undef wmemmove |
| 56 | #undef wmemset | 57 | #undef wmemset |
| 57 | 58 | ||
| 58 | _FORTIFY_FN(fgetws) wchar_t *fgetws(wchar_t *__s, int __n, FILE *__f) | 59 | _FORTIFY_FN(fgetws) wchar_t *fgetws(wchar_t * _FORTIFY_POS0 __s, |
| 60 | int __n, FILE *__f) | ||
| 59 | { | 61 | { |
| 60 | size_t __b = __bos(__s, 0); | 62 | size_t __b = __bos(__s, 0); |
| 61 | 63 | ||
| @@ -67,7 +69,8 @@ _FORTIFY_FN(fgetws) wchar_t *fgetws(wchar_t *__s, int __n, FILE *__f) | |||
| 67 | #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ | 69 | #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ |
| 68 | || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) | 70 | || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) |
| 69 | #undef mbsnrtowcs | 71 | #undef mbsnrtowcs |
| 70 | _FORTIFY_FN(mbsnrtowcs) size_t mbsnrtowcs(wchar_t *__d, const char **__s, size_t __n, | 72 | _FORTIFY_FN(mbsnrtowcs) size_t mbsnrtowcs(wchar_t * _FORTIFY_POS0 __d, |
| 73 | const char **__s, size_t __n, | ||
| 71 | size_t __wn, mbstate_t *__st) | 74 | size_t __wn, mbstate_t *__st) |
| 72 | { | 75 | { |
| 73 | size_t __b = __bos(__d, 0); | 76 | size_t __b = __bos(__d, 0); |
| @@ -87,7 +90,8 @@ _FORTIFY_FN(mbsnrtowcs) size_t mbsnrtowcs(wchar_t *__d, const char **__s, size_t | |||
| 87 | } | 90 | } |
| 88 | #endif | 91 | #endif |
| 89 | 92 | ||
| 90 | _FORTIFY_FN(mbsrtowcs) size_t mbsrtowcs(wchar_t *__d, const char **__s, size_t __wn, | 93 | _FORTIFY_FN(mbsrtowcs) size_t mbsrtowcs(wchar_t * _FORTIFY_POS0 __d, |
| 94 | const char **__s, size_t __wn, | ||
| 91 | mbstate_t *__st) | 95 | mbstate_t *__st) |
| 92 | { | 96 | { |
| 93 | size_t __b = __bos(__d, 0); | 97 | size_t __b = __bos(__d, 0); |
| @@ -100,7 +104,8 @@ _FORTIFY_FN(mbsrtowcs) size_t mbsrtowcs(wchar_t *__d, const char **__s, size_t _ | |||
| 100 | return __r; | 104 | return __r; |
| 101 | } | 105 | } |
| 102 | 106 | ||
| 103 | _FORTIFY_FN(mbstowcs) size_t mbstowcs(wchar_t *__ws, const char *__s, size_t __wn) | 107 | _FORTIFY_FN(mbstowcs) size_t mbstowcs(wchar_t * _FORTIFY_POS0 __ws, |
| 108 | const char *__s, size_t __wn) | ||
| 104 | { | 109 | { |
| 105 | size_t __b = __bos(__ws, 0); | 110 | size_t __b = __bos(__ws, 0); |
| 106 | 111 | ||
| @@ -109,7 +114,9 @@ _FORTIFY_FN(mbstowcs) size_t mbstowcs(wchar_t *__ws, const char *__s, size_t __w | |||
| 109 | return __orig_mbstowcs(__ws, __s, __wn); | 114 | return __orig_mbstowcs(__ws, __s, __wn); |
| 110 | } | 115 | } |
| 111 | 116 | ||
| 112 | _FORTIFY_FN(wcrtomb) size_t wcrtomb(char *__s, wchar_t __w, mbstate_t *__st) | 117 | /* FIXME clang */ |
| 118 | #ifndef __clang__ | ||
| 119 | _FORTIFY_FN(wcrtomb) size_t wcrtomb(char * __s, wchar_t __w, mbstate_t *__st) | ||
| 113 | { | 120 | { |
| 114 | if (__s && MB_LEN_MAX > __bos(__s, 2)) { | 121 | if (__s && MB_LEN_MAX > __bos(__s, 2)) { |
| 115 | char __buf[MB_LEN_MAX]; | 122 | char __buf[MB_LEN_MAX]; |
| @@ -125,8 +132,10 @@ _FORTIFY_FN(wcrtomb) size_t wcrtomb(char *__s, wchar_t __w, mbstate_t *__st) | |||
| 125 | } | 132 | } |
| 126 | return __orig_wcrtomb(__s, __w, __st); | 133 | return __orig_wcrtomb(__s, __w, __st); |
| 127 | } | 134 | } |
| 135 | #endif | ||
| 128 | 136 | ||
| 129 | _FORTIFY_FN(wcscat) wchar_t *wcscat(wchar_t *__d, const wchar_t *__s) | 137 | _FORTIFY_FN(wcscat) wchar_t *wcscat(wchar_t * _FORTIFY_POS0 __d, |
| 138 | const wchar_t *__s) | ||
| 130 | { | 139 | { |
| 131 | size_t __b = __bos(__d, 0); | 140 | size_t __b = __bos(__d, 0); |
| 132 | 141 | ||
| @@ -135,7 +144,8 @@ _FORTIFY_FN(wcscat) wchar_t *wcscat(wchar_t *__d, const wchar_t *__s) | |||
| 135 | return __orig_wcscat(__d, __s); | 144 | return __orig_wcscat(__d, __s); |
| 136 | } | 145 | } |
| 137 | 146 | ||
| 138 | _FORTIFY_FN(wcscpy) wchar_t *wcscpy(wchar_t *__d, const wchar_t *__s) | 147 | _FORTIFY_FN(wcscpy) wchar_t *wcscpy(wchar_t * _FORTIFY_POS0 __d, |
| 148 | const wchar_t *__s) | ||
| 139 | { | 149 | { |
| 140 | size_t __b = __bos(__d, 0); | 150 | size_t __b = __bos(__d, 0); |
| 141 | 151 | ||
| @@ -144,7 +154,8 @@ _FORTIFY_FN(wcscpy) wchar_t *wcscpy(wchar_t *__d, const wchar_t *__s) | |||
| 144 | return __orig_wcscpy(__d, __s); | 154 | return __orig_wcscpy(__d, __s); |
| 145 | } | 155 | } |
| 146 | 156 | ||
| 147 | _FORTIFY_FN(wcsncat) wchar_t *wcsncat(wchar_t *__d, const wchar_t *__s, size_t __n) | 157 | _FORTIFY_FN(wcsncat) wchar_t *wcsncat(wchar_t * _FORTIFY_POS0 __d, |
| 158 | const wchar_t *__s, size_t __n) | ||
| 148 | { | 159 | { |
| 149 | size_t __b = __bos(__d, 0); | 160 | size_t __b = __bos(__d, 0); |
| 150 | size_t __sl, __dl; | 161 | size_t __sl, __dl; |
| @@ -160,7 +171,8 @@ _FORTIFY_FN(wcsncat) wchar_t *wcsncat(wchar_t *__d, const wchar_t *__s, size_t _ | |||
| 160 | return __orig_wcsncat(__d, __s, __n); | 171 | return __orig_wcsncat(__d, __s, __n); |
| 161 | } | 172 | } |
| 162 | 173 | ||
| 163 | _FORTIFY_FN(wcsncpy) wchar_t *wcsncpy(wchar_t *__d, const wchar_t *__s, size_t __n) | 174 | _FORTIFY_FN(wcsncpy) wchar_t *wcsncpy(wchar_t * _FORTIFY_POS0 __d, |
| 175 | const wchar_t *__s, size_t __n) | ||
| 164 | { | 176 | { |
| 165 | size_t __b = __bos(__d, 0); | 177 | size_t __b = __bos(__d, 0); |
| 166 | 178 | ||
| @@ -172,7 +184,8 @@ _FORTIFY_FN(wcsncpy) wchar_t *wcsncpy(wchar_t *__d, const wchar_t *__s, size_t _ | |||
| 172 | #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ | 184 | #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ |
| 173 | || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) | 185 | || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) |
| 174 | #undef wcsnrtombs | 186 | #undef wcsnrtombs |
| 175 | _FORTIFY_FN(wcsnrtombs) size_t wcsnrtombs(char *__d, const wchar_t **__s, size_t __wn, | 187 | _FORTIFY_FN(wcsnrtombs) size_t wcsnrtombs(char * _FORTIFY_POS0 __d, |
| 188 | const wchar_t **__s, size_t __wn, | ||
| 176 | size_t __n, mbstate_t *__st) | 189 | size_t __n, mbstate_t *__st) |
| 177 | { | 190 | { |
| 178 | size_t __b = __bos(__d, 0); | 191 | size_t __b = __bos(__d, 0); |
| @@ -192,7 +205,8 @@ _FORTIFY_FN(wcsnrtombs) size_t wcsnrtombs(char *__d, const wchar_t **__s, size_t | |||
| 192 | } | 205 | } |
| 193 | #endif | 206 | #endif |
| 194 | 207 | ||
| 195 | _FORTIFY_FN(wcsrtombs) size_t wcsrtombs(char *__d, const wchar_t **__s, size_t __n, | 208 | _FORTIFY_FN(wcsrtombs) size_t wcsrtombs(char * _FORTIFY_POS0 __d, |
| 209 | const wchar_t **__s, size_t __n, | ||
| 196 | mbstate_t *__st) | 210 | mbstate_t *__st) |
| 197 | { | 211 | { |
| 198 | size_t __b = __bos(__d, 0); | 212 | size_t __b = __bos(__d, 0); |
| @@ -204,7 +218,8 @@ _FORTIFY_FN(wcsrtombs) size_t wcsrtombs(char *__d, const wchar_t **__s, size_t _ | |||
| 204 | return __r; | 218 | return __r; |
| 205 | } | 219 | } |
| 206 | 220 | ||
| 207 | _FORTIFY_FN(wcstombs) size_t wcstombs(char *__s, const wchar_t *__ws, size_t __n) | 221 | _FORTIFY_FN(wcstombs) size_t wcstombs(char * _FORTIFY_POS0 __s, |
| 222 | const wchar_t *__ws, size_t __n) | ||
| 208 | { | 223 | { |
| 209 | size_t __b = __bos(__s, 0); | 224 | size_t __b = __bos(__s, 0); |
| 210 | 225 | ||
| @@ -213,7 +228,7 @@ _FORTIFY_FN(wcstombs) size_t wcstombs(char *__s, const wchar_t *__ws, size_t __n | |||
| 213 | return __orig_wcstombs(__s, __ws, __n); | 228 | return __orig_wcstombs(__s, __ws, __n); |
| 214 | } | 229 | } |
| 215 | 230 | ||
| 216 | _FORTIFY_FN(wctomb) int wctomb(char *__s, wchar_t __w) | 231 | _FORTIFY_FN(wctomb) int wctomb(char * _FORTIFY_POS0 __s, wchar_t __w) |
| 217 | { | 232 | { |
| 218 | size_t __b = __bos(__s, 0); | 233 | size_t __b = __bos(__s, 0); |
| 219 | 234 | ||
| @@ -222,7 +237,8 @@ _FORTIFY_FN(wctomb) int wctomb(char *__s, wchar_t __w) | |||
| 222 | return __orig_wctomb(__s, __w); | 237 | return __orig_wctomb(__s, __w); |
| 223 | } | 238 | } |
| 224 | 239 | ||
| 225 | _FORTIFY_FN(wmemcpy) wchar_t *wmemcpy(wchar_t *__d, const wchar_t *__s, size_t __n) | 240 | _FORTIFY_FN(wmemcpy) wchar_t *wmemcpy(wchar_t * _FORTIFY_POS0 __d, |
| 241 | const wchar_t *__s, size_t __n) | ||
| 226 | { | 242 | { |
| 227 | size_t __b = __bos(__d, 0); | 243 | size_t __b = __bos(__d, 0); |
| 228 | 244 | ||
| @@ -231,7 +247,8 @@ _FORTIFY_FN(wmemcpy) wchar_t *wmemcpy(wchar_t *__d, const wchar_t *__s, size_t _ | |||
| 231 | return __orig_wmemcpy(__d, __s, __n); | 247 | return __orig_wmemcpy(__d, __s, __n); |
| 232 | } | 248 | } |
| 233 | 249 | ||
| 234 | _FORTIFY_FN(wmemmove) wchar_t *wmemmove(wchar_t *__d, const wchar_t *__s, size_t __n) | 250 | _FORTIFY_FN(wmemmove) wchar_t *wmemmove(wchar_t * _FORTIFY_POS0 __d, |
| 251 | const wchar_t *__s, size_t __n) | ||
| 235 | { | 252 | { |
| 236 | size_t __b = __bos(__d, 0); | 253 | size_t __b = __bos(__d, 0); |
| 237 | 254 | ||
| @@ -240,7 +257,8 @@ _FORTIFY_FN(wmemmove) wchar_t *wmemmove(wchar_t *__d, const wchar_t *__s, size_t | |||
| 240 | return __orig_wmemmove(__d, __s, __n); | 257 | return __orig_wmemmove(__d, __s, __n); |
| 241 | } | 258 | } |
| 242 | 259 | ||
| 243 | _FORTIFY_FN(wmemset) wchar_t *wmemset(wchar_t *__s, wchar_t __c, size_t __n) | 260 | _FORTIFY_FN(wmemset) wchar_t *wmemset(wchar_t * _FORTIFY_POS0 __s, |
| 261 | wchar_t __c, size_t __n) | ||
| 244 | { | 262 | { |
| 245 | size_t __b = __bos(__s, 0); | 263 | size_t __b = __bos(__s, 0); |
| 246 | 264 | ||
