From 2832fd8b8fc447656f0f56373db3cf41a48df31a Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sun, 5 Jun 2016 23:18:30 -0400 Subject: [PATCH] mke2fs: warn if user provides a label which is too long Addresses-Debian-Bug: #791630 Signed-off-by: Theodore Ts'o --- lib/ext2fs/ext2_fs.h | 4 +++- misc/mke2fs.c | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/ext2fs/ext2_fs.h b/lib/ext2fs/ext2_fs.h index ee9a5f20..27a7d3a7 100644 --- a/lib/ext2fs/ext2_fs.h +++ b/lib/ext2fs/ext2_fs.h @@ -602,6 +602,8 @@ struct ext2_inode *EXT2_INODE(struct ext2_inode_large *large_inode) #define EXT4_MAX_SALT_SIZE 256 #define EXT4_PBKDF2_ITERATIONS 0xFFFF +#define EXT2_LABEL_LEN 16 + /* * Policy provided via an ioctl on the topmost directory. This * structure is also in the kernel. @@ -669,7 +671,7 @@ struct ext2_super_block { __u32 s_feature_incompat; /* incompatible feature set */ __u32 s_feature_ro_compat; /* readonly-compatible feature set */ __u8 s_uuid[16]; /* 128-bit uuid for volume */ - char s_volume_name[16]; /* volume name */ + char s_volume_name[EXT2_LABEL_LEN]; /* volume name */ char s_last_mounted[64]; /* directory where last mounted */ __u32 s_algorithm_usage_bitmap; /* For compression */ /* diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 8107405d..7dc49b73 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -1699,6 +1699,11 @@ profile_error: break; case 'L': volume_label = optarg; + if (strlen(volume_label) > EXT2_LABEL_LEN) { + volume_label[EXT2_LABEL_LEN] = '\0'; + fprintf(stderr, _("Warning: label too long; will be truncated to '%s'\n\n"), + volume_label); + } break; case 'm': reserved_ratio = strtod(optarg, &tmp); -- 2.11.0