summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/fortify-headers.h33
-rw-r--r--include/poll.h7
-rw-r--r--include/stdio.h37
-rw-r--r--include/stdlib.h4
-rw-r--r--include/string.h33
-rw-r--r--include/strings.h6
-rw-r--r--include/sys/select.h13
-rw-r--r--include/sys/socket.h13
-rw-r--r--include/unistd.h30
-rw-r--r--include/wchar.h50
10 files changed, 163 insertions, 63 deletions
diff --git a/include/fortify-headers.h b/include/fortify-headers.h
index a37cd4a..b116290 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,14 +17,38 @@
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#if _FORTIFY_SOURCE > 2 && defined __has_attribute && __has_attribute(pass_dynamic_object_size)
23#define _FORTIFY_POSN(n) const __attribute__((pass_dynamic_object_size(n)))
24#else
25/* clang uses overloads; see https://github.com/llvm/llvm-project/issues/53516 */
26#define _FORTIFY_POSN(n) const __attribute__((pass_object_size__(n)))
27#endif
28
29/* we can't use extern inline with overloads without making them external */
30#define _FORTIFY_INLINE static __inline__ \
31 __attribute__((__always_inline__,__artificial__,__overloadable__))
32
33#else /* !__clang__ */
34
35#define _FORTIFY_POSN(n)
36#define _FORTIFY_INLINE extern __inline__ \
37 __attribute__((__always_inline__,__gnu_inline__,__artificial__))
38
39#endif /* __clang__ */
40
41#define _FORTIFY_POS0 _FORTIFY_POSN(0)
42#define _FORTIFY_POS1 _FORTIFY_POSN(1)
43#define _FORTIFY_POS2 _FORTIFY_POSN(2)
44
19#define _FORTIFY_STR(s) #s 45#define _FORTIFY_STR(s) #s
20#define _FORTIFY_ORIG(p,fn) __typeof__(fn) __orig_##fn __asm__(_FORTIFY_STR(p) #fn) 46#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); \ 47#define _FORTIFY_FNB(fn) _FORTIFY_ORIG(__USER_LABEL_PREFIX__,fn)
22 extern __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__)) 48#define _FORTIFY_FN(fn) _FORTIFY_FNB(fn); _FORTIFY_INLINE
23 49
24 50
25/* Use __builtin_dynamic_object_size with _FORTIFY_SOURCE>2, if available. */ 51#if _FORTIFY_SOURCE > 2 && defined __has_builtin && __has_builtin (__builtin_dynamic_object_size)
26#if _FORTIFY_SOURCE > 2 && defined __has_builtin && __has_builtin (__builtin_dynamic_object_size)
27#define __bos(ptr, type) __builtin_dynamic_object_size (ptr, type) 52#define __bos(ptr, type) __builtin_dynamic_object_size (ptr, type)
28#else 53#else
29#define __bos(ptr, type) __builtin_object_size (ptr, type) 54#define __bos(ptr, type) __builtin_object_size (ptr, type)
diff --git a/include/poll.h b/include/poll.h
index da0ffcc..4f5e69c 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 __typeof__(sizeof 0) __b = __bos(__f, 0); 36 __typeof__(sizeof 0) __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) && (!defined(_REDIR_TIME64) || !_REDIR_TIME64) 43#if defined(_GNU_SOURCE) && (!defined(_REDIR_TIME64) || !_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 __typeof__(sizeof 0) __b = __bos(__f, 0); 48 __typeof__(sizeof 0) __b = __bos(__f, 0);
48 49
diff --git a/include/stdio.h b/include/stdio.h
index e060f64..a75c9ea 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.
@@ -36,7 +37,7 @@ extern "C" {
36#undef snprintf 37#undef snprintf
37#undef sprintf 38#undef sprintf
38 39
39_FORTIFY_FN(fgets) char *fgets(char *__s, int __n, FILE *__f) 40_FORTIFY_FN(fgets) char *fgets(char * _FORTIFY_POS0 __s, int __n, FILE *__f)
40{ 41{
41 size_t __b = __bos(__s, 0); 42 size_t __b = __bos(__s, 0);
42 43
@@ -45,7 +46,8 @@ _FORTIFY_FN(fgets) char *fgets(char *__s, int __n, FILE *__f)
45 return __orig_fgets(__s, __n, __f); 46 return __orig_fgets(__s, __n, __f);
46} 47}
47 48
48_FORTIFY_FN(fread) size_t fread(void *__d, size_t __n, size_t __m, FILE *__f) 49_FORTIFY_FN(fread) size_t fread(void * _FORTIFY_POS0 __d, size_t __n,
50 size_t __m, FILE *__f)
49{ 51{
50 size_t __b = __bos(__d, 0); 52 size_t __b = __bos(__d, 0);
51 53
@@ -56,7 +58,8 @@ _FORTIFY_FN(fread) size_t fread(void *__d, size_t __n, size_t __m, FILE *__f)
56 return __orig_fread(__d, __n, __m, __f); 58 return __orig_fread(__d, __n, __m, __f);
57} 59}
58 60
59_FORTIFY_FN(fwrite) size_t fwrite(const void *__d, size_t __n, size_t __m, FILE *__f) 61_FORTIFY_FN(fwrite) size_t fwrite(const void * _FORTIFY_POS0 __d, size_t __n,
62 size_t __m, FILE *__f)
60{ 63{
61 size_t __b = __bos(__d, 0); 64 size_t __b = __bos(__d, 0);
62 65
@@ -67,8 +70,8 @@ _FORTIFY_FN(fwrite) size_t fwrite(const void *__d, size_t __n, size_t __m, FILE
67 return __orig_fwrite(__d, __n, __m, __f); 70 return __orig_fwrite(__d, __n, __m, __f);
68} 71}
69 72
70_FORTIFY_FN(vsnprintf) int vsnprintf(char *__s, size_t __n, const char *__f, 73_FORTIFY_FN(vsnprintf) int vsnprintf(char * _FORTIFY_POS0 __s, size_t __n,
71 __builtin_va_list __v) 74 const char *__f, __builtin_va_list __v)
72{ 75{
73 size_t __b = __bos(__s, 0); 76 size_t __b = __bos(__s, 0);
74 77
@@ -77,7 +80,8 @@ _FORTIFY_FN(vsnprintf) int vsnprintf(char *__s, size_t __n, const char *__f,
77 return __orig_vsnprintf(__s, __n, __f, __v); 80 return __orig_vsnprintf(__s, __n, __f, __v);
78} 81}
79 82
80_FORTIFY_FN(vsprintf) int vsprintf(char *__s, const char *__f, __builtin_va_list __v) 83_FORTIFY_FN(vsprintf) int vsprintf(char * _FORTIFY_POS0 __s, const char *__f,
84 __builtin_va_list __v)
81{ 85{
82 size_t __b = __bos(__s, 0); 86 size_t __b = __bos(__s, 0);
83 int __r; 87 int __r;
@@ -92,7 +96,23 @@ _FORTIFY_FN(vsprintf) int vsprintf(char *__s, const char *__f, __builtin_va_list
92 return __r; 96 return __r;
93} 97}
94 98
95_FORTIFY_FN(snprintf) int snprintf(char *__s, size_t __n, const char *__f, ...) 99#if defined(__has_builtin)
100#if __has_builtin(__builtin_va_arg_pack)
101
102/* clang is missing __builtin_va_arg_pack, so we cannot use these impls
103 * outside of gcc; we then have a few options:
104 *
105 * 1) using va_start/end and implementing these functions as static inline,
106 * with inlining never happening; that means extra symbols with internal
107 * linkage, which is not ideal
108 * 2) using macros; this is incompatible with c++ and since musl does not
109 * have the __chk variants, we'd need to implement a body with intermediate
110 * variables within the macro, which means more non-portable mess
111 * 3) not implementing these under clang, which is what we do for now
112 */
113
114_FORTIFY_FN(snprintf) int snprintf(char *__s, size_t __n,
115 const char *__f, ...)
96{ 116{
97 size_t __b = __bos(__s, 0); 117 size_t __b = __bos(__s, 0);
98 118
@@ -116,6 +136,9 @@ _FORTIFY_FN(sprintf) int sprintf(char *__s, const char *__f, ...)
116 return __r; 136 return __r;
117} 137}
118 138
139#endif /* __has_builtin(__builtin_va_arg_pack) */
140#endif /* defined(__has_builtin) */
141
119#ifdef __cplusplus 142#ifdef __cplusplus
120} 143}
121#endif 144#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__
35extern "C" { 36extern "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 f9f6701..9fc1cd4 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.
@@ -36,7 +37,8 @@ extern "C" {
36#undef strncat 37#undef strncat
37#undef strncpy 38#undef strncpy
38 39
39_FORTIFY_FN(memcpy) void *memcpy(void *__od, const void *__os, size_t __n) 40_FORTIFY_FN(memcpy) void *memcpy(void * _FORTIFY_POS0 __od,
41 const void * _FORTIFY_POS0 __os, size_t __n)
40{ 42{
41 size_t __bd = __bos(__od, 0); 43 size_t __bd = __bos(__od, 0);
42 size_t __bs = __bos(__os, 0); 44 size_t __bs = __bos(__os, 0);
@@ -53,7 +55,8 @@ _FORTIFY_FN(memcpy) void *memcpy(void *__od, const void *__os, size_t __n)
53 return __builtin_memcpy(__od, __os, __n); 55 return __builtin_memcpy(__od, __os, __n);
54} 56}
55 57
56_FORTIFY_FN(memmove) void *memmove(void *__d, const void *__s, size_t __n) 58_FORTIFY_FN(memmove) void *memmove(void * _FORTIFY_POS0 __d,
59 const void * _FORTIFY_POS0 __s, size_t __n)
57{ 60{
58 size_t __bd = __bos(__d, 0); 61 size_t __bd = __bos(__d, 0);
59 size_t __bs = __bos(__s, 0); 62 size_t __bs = __bos(__s, 0);
@@ -63,7 +66,7 @@ _FORTIFY_FN(memmove) void *memmove(void *__d, const void *__s, size_t __n)
63 return __orig_memmove(__d, __s, __n); 66 return __orig_memmove(__d, __s, __n);
64} 67}
65 68
66_FORTIFY_FN(memset) void *memset(void *__d, int __c, size_t __n) 69_FORTIFY_FN(memset) void *memset(void * _FORTIFY_POS0 __d, int __c, size_t __n)
67{ 70{
68 size_t __b = __bos(__d, 0); 71 size_t __b = __bos(__d, 0);
69 72
@@ -76,7 +79,7 @@ _FORTIFY_FN(memset) void *memset(void *__d, int __c, size_t __n)
76 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ 79 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
77 || defined(_BSD_SOURCE) 80 || defined(_BSD_SOURCE)
78#undef stpcpy 81#undef stpcpy
79_FORTIFY_FN(stpcpy) char *stpcpy(char *__d, const char *__s) 82_FORTIFY_FN(stpcpy) char *stpcpy(char * _FORTIFY_POS0 __d, const char *__s)
80{ 83{
81 size_t __b = __bos(__d, 0); 84 size_t __b = __bos(__d, 0);
82 85
@@ -86,7 +89,8 @@ _FORTIFY_FN(stpcpy) char *stpcpy(char *__d, const char *__s)
86} 89}
87 90
88#undef stpncpy 91#undef stpncpy
89_FORTIFY_FN(stpncpy) char *stpncpy(char *__d, const char *__s, size_t __n) 92_FORTIFY_FN(stpncpy) char *stpncpy(char * _FORTIFY_POS0 __d, const char *__s,
93 size_t __n)
90{ 94{
91 size_t __b = __bos(__d, 0); 95 size_t __b = __bos(__d, 0);
92 96
@@ -96,7 +100,7 @@ _FORTIFY_FN(stpncpy) char *stpncpy(char *__d, const char *__s, size_t __n)
96} 100}
97#endif 101#endif
98 102
99_FORTIFY_FN(strcat) char *strcat(char *__d, const char *__s) 103_FORTIFY_FN(strcat) char *strcat(char * _FORTIFY_POS0 __d, const char *__s)
100{ 104{
101 size_t __b = __bos(__d, 0); 105 size_t __b = __bos(__d, 0);
102 106
@@ -105,7 +109,7 @@ _FORTIFY_FN(strcat) char *strcat(char *__d, const char *__s)
105 return __orig_strcat(__d, __s); 109 return __orig_strcat(__d, __s);
106} 110}
107 111
108_FORTIFY_FN(strcpy) char *strcpy(char *__d, const char *__s) 112_FORTIFY_FN(strcpy) char *strcpy(char * _FORTIFY_POS0 __d, const char *__s)
109{ 113{
110 size_t __b = __bos(__d, 0); 114 size_t __b = __bos(__d, 0);
111 115
@@ -114,7 +118,8 @@ _FORTIFY_FN(strcpy) char *strcpy(char *__d, const char *__s)
114 return __orig_strcpy(__d, __s); 118 return __orig_strcpy(__d, __s);
115} 119}
116 120
117_FORTIFY_FN(strncat) char *strncat(char *__d, const char *__s, size_t __n) 121_FORTIFY_FN(strncat) char *strncat(char * _FORTIFY_POS0 __d, const char *__s,
122 size_t __n)
118{ 123{
119 size_t __b = __bos(__d, 0); 124 size_t __b = __bos(__d, 0);
120 size_t __sl, __dl; 125 size_t __sl, __dl;
@@ -130,7 +135,8 @@ _FORTIFY_FN(strncat) char *strncat(char *__d, const char *__s, size_t __n)
130 return __orig_strncat(__d, __s, __n); 135 return __orig_strncat(__d, __s, __n);
131} 136}
132 137
133_FORTIFY_FN(strncpy) char *strncpy(char *__d, const char *__s, size_t __n) 138_FORTIFY_FN(strncpy) char *strncpy(char * _FORTIFY_POS0 __d,
139 const char *__s, size_t __n)
134{ 140{
135 size_t __b = __bos(__d, 0); 141 size_t __b = __bos(__d, 0);
136 142
@@ -141,7 +147,8 @@ _FORTIFY_FN(strncpy) char *strncpy(char *__d, const char *__s, size_t __n)
141 147
142#ifdef _GNU_SOURCE 148#ifdef _GNU_SOURCE
143#undef mempcpy 149#undef mempcpy
144_FORTIFY_FN(mempcpy) void *mempcpy(void *__d, const void *__s, size_t __n) 150_FORTIFY_FN(mempcpy) void *mempcpy(void * _FORTIFY_POS0 __d,
151 const void * _FORTIFY_POS0 __s, size_t __n)
145{ 152{
146 size_t __bd = __bos(__d, 0); 153 size_t __bd = __bos(__d, 0);
147 size_t __bs = __bos(__s, 0); 154 size_t __bs = __bos(__s, 0);
@@ -155,7 +162,8 @@ _FORTIFY_FN(mempcpy) void *mempcpy(void *__d, const void *__s, size_t __n)
155#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 162#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
156#undef strlcat 163#undef strlcat
157#undef strlcpy 164#undef strlcpy
158_FORTIFY_FN(strlcat) size_t strlcat(char *__d, const char *__s, size_t __n) 165_FORTIFY_FN(strlcat) size_t strlcat(char * _FORTIFY_POS0 __d,
166 const char *__s, size_t __n)
159{ 167{
160 size_t __b = __bos(__d, 0); 168 size_t __b = __bos(__d, 0);
161 169
@@ -164,7 +172,8 @@ _FORTIFY_FN(strlcat) size_t strlcat(char *__d, const char *__s, size_t __n)
164 return __orig_strlcat(__d, __s, __n); 172 return __orig_strlcat(__d, __s, __n);
165} 173}
166 174
167_FORTIFY_FN(strlcpy) size_t strlcpy(char *__d, const char *__s, size_t __n) 175_FORTIFY_FN(strlcpy) size_t strlcpy(char * _FORTIFY_POS0 __d,
176 const char *__s, size_t __n)
168{ 177{
169 size_t __b = __bos(__d, 0); 178 size_t __b = __bos(__d, 0);
170 179
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__
27extern "C" { 28extern "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
30static __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__)) 37static __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__))
31void __fortify_FD_CLR(int __f, fd_set *__s) 38void __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
40static __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__)) 47static __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__))
41void __fortify_FD_SET(int __f, fd_set *__s) 48void __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