Whamcloud - gitweb
mke2fs: warn if user provides a label which is too long
authorTheodore Ts'o <tytso@mit.edu>
Mon, 6 Jun 2016 03:18:30 +0000 (23:18 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 6 Jun 2016 03:18:30 +0000 (23:18 -0400)
Addresses-Debian-Bug: #791630

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/ext2_fs.h
misc/mke2fs.c

index ee9a5f2..27a7d3a 100644 (file)
@@ -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 */
        /*
index 8107405..7dc49b7 100644 (file)
@@ -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);