summaryrefslogtreecommitdiff
path: root/test-str.c
diff options
context:
space:
mode:
authorSteve McIntyre <steve@einval.com>2022-06-23 00:16:56 +0100
committerSteve McIntyre <steve@einval.com>2022-06-23 00:16:56 +0100
commite6ace38abd705fbe24349152b7c90d473404e86e (patch)
tree50e7a2d6b00d650fcbee8b0c54f0a0eacefc6929 /test-str.c
parent8529e0f7f70f427a7202815061362eceba6bfc50 (diff)
downloadefi-boot-shim-upstream/15.6.tar.gz
efi-boot-shim-upstream/15.6.zip
New upstream version 15.6upstream/15.6
Diffstat (limited to 'test-str.c')
-rw-r--r--test-str.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/test-str.c b/test-str.c
index 9cb831de..30f8dd0b 100644
--- a/test-str.c
+++ b/test-str.c
@@ -926,12 +926,15 @@ static int
test_strncpy(void)
{
char s[] = "0123456789abcdef\0000";
- char s0[4096+4096];
- char *s1 = &s0[4096];
+ char s0[4096];
+ char s1[4096];
memset(s0, 0, sizeof(s0));
memcpy(s0, s, sizeof(s));
-
+#if __GNUC_PREREQ(8, 1)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wstringop-truncation"
+#endif
memset(s1, 0, 4096);
assert_equal_return(strncpy(s1, s0, 0), s1, -1, "got %p expected %p\n");
assert_equal_return(strlen(s1), 0, -1, "got %d expected %d\n");
@@ -1030,7 +1033,9 @@ test_strncpy(void)
assert_equal_return(s1[16], '\000', -1, "got %#02hhx expected %02hhx\n");
assert_equal_return(s1[17], '0', -1, "got %#02hhx expected %02hhx\n");
assert_equal_return(s1[18], '1', -1, "got %#02hhx expected %02hhx\n");
-
+#if __GNUC_PREREQ(8, 1)
+# pragma GCC diagnostic pop
+#endif
return 0;
}
@@ -1038,12 +1043,12 @@ static int
test_strcat(void)
{
char s[] = "0123456789abcdef\0000";
- char s0[8192];
- char *s1 = &s0[4096];
+ char s0[4096];
+ char s1[4096];
char *s2;
char s3[] = "0123456789abcdef0123456789abcdef\000\000\000\000\000";
- memset(s0, 0, 8192);
+ memset(s0, 0, sizeof(s0));
memcpy(s0, s, sizeof(s));
memset(s1, 0, 4096);