Skip to content

Commit 986a6f5

Browse files
keesbrauner
authored andcommitted
vboxsf: Add __nonstring annotations for unterminated strings
When a character array without a terminating NUL character has a static initializer, GCC 15's -Wunterminated-string-initialization will only warn if the array lacks the "nonstring" attribute[1]. Mark the arrays with __nonstring to and correctly identify the char array as "not a C string" and thereby eliminate the warning. This effectively reverts the change in 4e74872 ("vboxsf: fix building with GCC 15"), to add the annotation that has other uses (i.e. warning if the string is ever used with C string APIs). Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117178 [1] Cc: Hans de Goede <hdegoede@redhat.com> Cc: Brahmajit Das <brahmajit.xyz@gmail.com> Cc: Christian Brauner <brauner@kernel.org> Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Kees Cook <kees@kernel.org> Link: https://lore.kernel.org/r/20250310222530.work.374-kees@kernel.org Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent accdd11 commit 986a6f5

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

fs/vboxsf/super.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121

2222
#define VBOXSF_SUPER_MAGIC 0x786f4256 /* 'VBox' little endian */
2323

24-
static const unsigned char VBSF_MOUNT_SIGNATURE[4] = { '\000', '\377', '\376',
25-
'\375' };
24+
static const unsigned char VBSF_MOUNT_SIGNATURE[4] __nonstring = "\000\377\376\375";
2625

2726
static int follow_symlinks;
2827
module_param(follow_symlinks, int, 0444);

0 commit comments

Comments
 (0)