summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorjvoisin2023-08-22 19:16:49 +0200
committerjvoisin2023-08-22 19:16:49 +0200
commitacfa9f6ce8295b2493b4e21b73463b93ef3c4333 (patch)
tree0b4ad45ed42caf5bf407f05ec75deb9ccba46ff5 /include
parent9231e0905829f1c33abe07bed9be35298c9bdcf5 (diff)
Add hardening for pwrite
Diffstat (limited to 'include')
-rw-r--r--include/unistd.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/unistd.h b/include/unistd.h
index 1c79711..e91f922 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -180,6 +180,17 @@ _FORTIFY_FN(write) ssize_t write(int __f, const void * _FORTIFY_POS0 __s,
180 return __orig_write(__f, __s, __n); 180 return __orig_write(__f, __s, __n);
181} 181}
182 182
183__diagnose_as_builtin(__builtin_pwrite, 1, 2, 3, 4)
184_FORTIFY_FN(pwrite) ssize_t pwrite(int __f, const void * _FORTIFY_POS0 __s,
185 size_t __n, off_t __o)
186{
187 size_t __b = __bos(__s, 0);
188
189 if (__n > __b)
190 __builtin_trap();
191 return __orig_pwrite(__f, __s, __n, __o);
192}
193
183#ifdef __cplusplus 194#ifdef __cplusplus
184} 195}
185#endif 196#endif