summaryrefslogtreecommitdiff
path: root/lib/test_fortify
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2021-06-16 14:42:23 -0700
committerKees Cook <keescook@chromium.org>2022-02-13 16:50:06 -0800
commit28e77cc1c0686621a4d416f599cee5ab369daa0a (patch)
treec58b0cfacdeab1d3f46cbd12f91ebcfb37a7ab56 /lib/test_fortify
parent938a000e3f9bead24ea753286b3e4d2423275c9e (diff)
fortify: Detect struct member overflows in memset() at compile-time
As done for memcpy(), also update memset() to use the same tightened compile-time bounds checking under CONFIG_FORTIFY_SOURCE. Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'lib/test_fortify')
-rw-r--r--lib/test_fortify/write_overflow_field-memset.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/test_fortify/write_overflow_field-memset.c b/lib/test_fortify/write_overflow_field-memset.c
new file mode 100644
index 000000000000..2331da26909e
--- /dev/null
+++ b/lib/test_fortify/write_overflow_field-memset.c
@@ -0,0 +1,5 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#define TEST \
+ memset(instance.buf, 0x42, sizeof(instance.buf) + 1)
+
+#include "test_fortify.h"