diff options
author | Richard Jones <rjones@redhat.com> | 2010-06-01 15:50:14 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2010-06-02 13:38:00 +0100 |
commit | 52f9cd4882135910ea06e1e50ac6441d455c9ab1 (patch) | |
tree | a5b6d72d2d3b136f0d3932a162b5b525f63fb208 /daemon/ext2.c | |
parent | 000f8059a53860ddf3319c1f54d4df5dcd6aa846 (diff) | |
download | libguestfs-52f9cd4882135910ea06e1e50ac6441d455c9ab1.tar.gz libguestfs-52f9cd4882135910ea06e1e50ac6441d455c9ab1.tar.xz libguestfs-52f9cd4882135910ea06e1e50ac6441d455c9ab1.zip |
daemon: Limit label lengths (RHBZ#597118).
Diffstat (limited to 'daemon/ext2.c')
-rw-r--r-- | daemon/ext2.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/daemon/ext2.c b/daemon/ext2.c index 7f9d2e02..b7ce627e 100644 --- a/daemon/ext2.c +++ b/daemon/ext2.c @@ -29,6 +29,9 @@ #include "c-ctype.h" #include "actions.h" +/* Confirmed this is true up to ext4 from the Linux sources. */ +#define EXT2_LABEL_MAX 16 + /* Choose which tools like mke2fs to use. For RHEL 5 (only) there * is a special set of tools which support ext2/3/4. eg. On RHEL 5, * mke2fs only supports ext2/3, but mke4fs supports ext2/3/4. @@ -156,6 +159,12 @@ do_set_e2label (const char *device, const char *label) if (e2prog (prog) == -1) return -1; + if (strlen (label) > EXT2_LABEL_MAX) { + reply_with_error ("%s: ext2 labels are limited to %d bytes", + label, EXT2_LABEL_MAX); + return -1; + } + r = command (NULL, &err, prog, device, label, NULL); if (r == -1) { reply_with_error ("%s", err); @@ -320,6 +329,12 @@ do_mke2journal_L (int blocksize, const char *label, const char *device) if (e2prog (prog) == -1) return -1; + if (strlen (label) > EXT2_LABEL_MAX) { + reply_with_error ("%s: ext2 labels are limited to %d bytes", + label, EXT2_LABEL_MAX); + return -1; + } + char blocksize_s[32]; snprintf (blocksize_s, sizeof blocksize_s, "%d", blocksize); @@ -406,6 +421,12 @@ do_mke2fs_JL (const char *fstype, int blocksize, const char *device, if (e2prog (prog) == -1) return -1; + if (strlen (label) > EXT2_LABEL_MAX) { + reply_with_error ("%s: ext2 labels are limited to %d bytes", + label, EXT2_LABEL_MAX); + return -1; + } + char blocksize_s[32]; snprintf (blocksize_s, sizeof blocksize_s, "%d", blocksize); |