summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorsin2015-01-29 12:14:06 +0000
committersin2015-01-29 12:14:06 +0000
commit4a18008ce14b77be67ed0b5f0e27b4db3db5beb8 (patch)
treeee87363fc11027c575244bf051c8dcf7de72a656 /include
parent3d159480208ecad607490f513784a3a68f817f42 (diff)
Add bzero() checks
Diffstat (limited to '')
-rw-r--r--include/strings.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/strings.h b/include/strings.h
index e81c8e0..d9a625d 100644
--- a/include/strings.h
+++ b/include/strings.h
@@ -21,8 +21,22 @@ __fortify_bcopy(const void *__restrict src, void *__restrict dest, size_t n)
21 return bcopy(src, dest, n); 21 return bcopy(src, dest, n);
22} 22}
23 23
24static inline __attribute__ ((always_inline))
25void
26__fortify_bzero(void *src, size_t n)
27{
28 size_t bos = __builtin_object_size(src, 0);
29
30 if (n > bos)
31 __builtin_trap();
32 return bzero(src, n);
33}
34
24#undef bcopy 35#undef bcopy
25#define bcopy(src, dest, n) __fortify_bcopy(src, dest, n) 36#define bcopy(src, dest, n) __fortify_bcopy(src, dest, n)
37#undef bzero
38#define bzero(src, n) __fortify_bzero(src, n)
39
26#endif 40#endif
27 41
28#endif 42#endif