summaryrefslogtreecommitdiffstats
path: root/daemon/swap.c
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2010-06-01 15:50:14 +0100
committerRichard Jones <rjones@redhat.com>2010-06-02 13:38:00 +0100
commit52f9cd4882135910ea06e1e50ac6441d455c9ab1 (patch)
treea5b6d72d2d3b136f0d3932a162b5b525f63fb208 /daemon/swap.c
parent000f8059a53860ddf3319c1f54d4df5dcd6aa846 (diff)
downloadlibguestfs-52f9cd4882135910ea06e1e50ac6441d455c9ab1.tar.gz
libguestfs-52f9cd4882135910ea06e1e50ac6441d455c9ab1.tar.xz
libguestfs-52f9cd4882135910ea06e1e50ac6441d455c9ab1.zip
daemon: Limit label lengths (RHBZ#597118).
Diffstat (limited to 'daemon/swap.c')
-rw-r--r--daemon/swap.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/daemon/swap.c b/daemon/swap.c
index f22f2dec..5de6ba61 100644
--- a/daemon/swap.c
+++ b/daemon/swap.c
@@ -28,6 +28,9 @@
#include "actions.h"
#include "optgroups.h"
+/* Confirmed this is true for Linux swap partitions from the Linux sources. */
+#define SWAP_LABEL_MAX 16
+
/* Convenient place to test for the later version of e2fsprogs
* and util-linux which supports -U parameters to specify UUIDs.
* (Not supported in RHEL 5).
@@ -77,6 +80,12 @@ do_mkswap (const char *device)
int
do_mkswap_L (const char *label, const char *device)
{
+ if (strlen (label) > SWAP_LABEL_MAX) {
+ reply_with_error ("%s: Linux swap labels are limited to %d bytes",
+ label, SWAP_LABEL_MAX);
+ return -1;
+ }
+
return mkswap (device, "-L", label);
}
@@ -179,12 +188,24 @@ do_swapoff_file (const char *path)
int
do_swapon_label (const char *label)
{
+ if (strlen (label) > SWAP_LABEL_MAX) {
+ reply_with_error ("%s: Linux swap labels are limited to %d bytes",
+ label, SWAP_LABEL_MAX);
+ return -1;
+ }
+
return swaponoff ("swapon", "-L", label);
}
int
do_swapoff_label (const char *label)
{
+ if (strlen (label) > SWAP_LABEL_MAX) {
+ reply_with_error ("%s: Linux swap labels are limited to %d bytes",
+ label, SWAP_LABEL_MAX);
+ return -1;
+ }
+
return swaponoff ("swapoff", "-L", label);
}