Fix potential buffer overwrite.
authorCarl Hetherington <cth@carlh.net>
Sun, 19 Jun 2022 20:52:28 +0000 (22:52 +0200)
committerCarl Hetherington <cth@carlh.net>
Sun, 19 Jun 2022 20:52:28 +0000 (22:52 +0200)
src/ext4_mkfs.c

index c6b89386ae6ce478df06a2052f4839ee09e04c3e..4ff2f75e7b2335c50c6d32a53ece861e10672052 100644 (file)
@@ -264,7 +264,7 @@ static void fill_sb(struct fs_aux_info *aux_info, struct ext4_mkfs_info *info)
        memcpy(sb->uuid, info->uuid, UUID_SIZE);
 
        memset(sb->volume_name, 0, sizeof(sb->volume_name));
-       strncpy(sb->volume_name, info->label, sizeof(sb->volume_name));
+       strncpy(sb->volume_name, info->label, sizeof(sb->volume_name) - 1);
        memset(sb->last_mounted, 0, sizeof(sb->last_mounted));
 
        sb->algorithm_usage_bitmap = to_le32(0);