From 87ceed399d6447ab5113c17c36c66be321dcb082 Mon Sep 17 00:00:00 2001 From: asomers Date: Tue, 30 Jul 2019 17:31:09 +0000 Subject: [PATCH] fusefs: nul-terminate some strings in the readdir test Reported by: GCC 8 Sponsored by: The FreeBSD Foundation --- tests/sys/fs/fusefs/readdir.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/sys/fs/fusefs/readdir.cc b/tests/sys/fs/fusefs/readdir.cc index db207790ed7..24373bebf1b 100644 --- a/tests/sys/fs/fusefs/readdir.cc +++ b/tests/sys/fs/fusefs/readdir.cc @@ -70,19 +70,19 @@ TEST_F(Readdir, dots) struct dirent *de; vector ents(2); vector empty_ents(0); - const char *dot = "."; - const char *dotdot = ".."; + const char dot[] = "."; + const char dotdot[] = ".."; expect_lookup(RELPATH, ino); expect_opendir(ino); ents[0].d_fileno = 2; ents[0].d_off = 2000; - ents[0].d_namlen = strlen(dotdot); + ents[0].d_namlen = sizeof(dotdot); ents[0].d_type = DT_DIR; strncpy(ents[0].d_name, dotdot, ents[0].d_namlen); ents[1].d_fileno = 3; ents[1].d_off = 3000; - ents[1].d_namlen = strlen(dot); + ents[1].d_namlen = sizeof(dot); ents[1].d_type = DT_DIR; strncpy(ents[1].d_name, dot, ents[1].d_namlen); expect_readdir(ino, 0, ents); @@ -102,8 +102,8 @@ TEST_F(Readdir, dots) */ //EXPECT_EQ(2000, de->d_off); EXPECT_EQ(DT_DIR, de->d_type); - EXPECT_EQ(2, de->d_namlen); - EXPECT_EQ(0, strcmp("..", de->d_name)); + EXPECT_EQ(sizeof(dotdot), de->d_namlen); + EXPECT_EQ(0, strcmp(dotdot, de->d_name)); errno = 0; de = readdir(dir); @@ -111,8 +111,8 @@ TEST_F(Readdir, dots) EXPECT_EQ(3ul, de->d_fileno); //EXPECT_EQ(3000, de->d_off); EXPECT_EQ(DT_DIR, de->d_type); - EXPECT_EQ(1, de->d_namlen); - EXPECT_EQ(0, strcmp(".", de->d_name)); + EXPECT_EQ(sizeof(dot), de->d_namlen); + EXPECT_EQ(0, strcmp(dot, de->d_name)); ASSERT_EQ(nullptr, readdir(dir)); ASSERT_EQ(0, errno); -- 2.45.0