|
|
0d20ef |
From 9dc43745b5330e5cd56b882f72ba160ab80cf7b1 Mon Sep 17 00:00:00 2001
|
|
|
0d20ef |
From: Pino Toscano <ptoscano@redhat.com>
|
|
|
0d20ef |
Date: Wed, 12 Nov 2014 09:50:59 +0100
|
|
|
0d20ef |
Subject: [PATCH] daemon: check xfs label lengths (RHBZ#1162966).
|
|
|
0d20ef |
|
|
|
0d20ef |
Similar to commit 52f9cd4882135910ea06e1e50ac6441d455c9ab1, but for xfs
|
|
|
0d20ef |
filesystems.
|
|
|
0d20ef |
|
|
|
0d20ef |
(cherry picked from commit 57547dcdcfb27bdd988d8a561dc2178ea1d23517)
|
|
|
0d20ef |
---
|
|
|
0d20ef |
daemon/daemon.h | 4 ++++
|
|
|
0d20ef |
daemon/labels.c | 6 ++++++
|
|
|
0d20ef |
daemon/xfs.c | 6 ++++++
|
|
|
0d20ef |
3 files changed, 16 insertions(+)
|
|
|
0d20ef |
|
|
|
0d20ef |
diff --git a/daemon/daemon.h b/daemon/daemon.h
|
|
|
0d20ef |
index 0ccbc9e..f442efd 100644
|
|
|
0d20ef |
--- a/daemon/daemon.h
|
|
|
0d20ef |
+++ b/daemon/daemon.h
|
|
|
0d20ef |
@@ -253,6 +253,10 @@ extern void main_loop (int sock) __attribute__((noreturn));
|
|
|
0d20ef |
/*-- in xattr.c --*/
|
|
|
0d20ef |
extern int copy_xattrs (const char *src, const char *dest);
|
|
|
0d20ef |
|
|
|
0d20ef |
+/*-- in xfs.c --*/
|
|
|
0d20ef |
+/* Documented in xfs_admin(8). */
|
|
|
0d20ef |
+#define XFS_LABEL_MAX 12
|
|
|
0d20ef |
+
|
|
|
0d20ef |
/* ordinary daemon functions use these to indicate errors
|
|
|
0d20ef |
* NB: you don't need to prefix the string with the current command,
|
|
|
0d20ef |
* it is added automatically by the client-side RPC stubs.
|
|
|
0d20ef |
diff --git a/daemon/labels.c b/daemon/labels.c
|
|
|
0d20ef |
index f417c57..cfcb4df 100644
|
|
|
0d20ef |
--- a/daemon/labels.c
|
|
|
0d20ef |
+++ b/daemon/labels.c
|
|
|
0d20ef |
@@ -118,6 +118,12 @@ xfslabel (const char *device, const char *label)
|
|
|
0d20ef |
return -1;
|
|
|
0d20ef |
}
|
|
|
0d20ef |
|
|
|
0d20ef |
+ if (strlen (label) > XFS_LABEL_MAX) {
|
|
|
0d20ef |
+ reply_with_error ("%s: xfs labels are limited to %d bytes",
|
|
|
0d20ef |
+ label, XFS_LABEL_MAX);
|
|
|
0d20ef |
+ return -1;
|
|
|
0d20ef |
+ }
|
|
|
0d20ef |
+
|
|
|
0d20ef |
r = command (NULL, &err, str_xfs_admin, "-L", label, device, NULL);
|
|
|
0d20ef |
if (r == -1) {
|
|
|
0d20ef |
reply_with_error ("%s", err);
|
|
|
0d20ef |
diff --git a/daemon/xfs.c b/daemon/xfs.c
|
|
|
0d20ef |
index 725f7b3..687013b 100644
|
|
|
0d20ef |
--- a/daemon/xfs.c
|
|
|
0d20ef |
+++ b/daemon/xfs.c
|
|
|
0d20ef |
@@ -498,6 +498,12 @@ do_xfs_admin (const char *device,
|
|
|
0d20ef |
}
|
|
|
0d20ef |
|
|
|
0d20ef |
if (optargs_bitmask & GUESTFS_XFS_ADMIN_LABEL_BITMASK) {
|
|
|
0d20ef |
+ if (strlen (label) > XFS_LABEL_MAX) {
|
|
|
0d20ef |
+ reply_with_error ("%s: xfs labels are limited to %d bytes",
|
|
|
0d20ef |
+ label, XFS_LABEL_MAX);
|
|
|
0d20ef |
+ return -1;
|
|
|
0d20ef |
+ }
|
|
|
0d20ef |
+
|
|
|
0d20ef |
ADD_ARG (argv, i, "-L");
|
|
|
0d20ef |
ADD_ARG (argv, i, label);
|
|
|
0d20ef |
}
|
|
|
0d20ef |
--
|
|
|
0d20ef |
1.8.3.1
|
|
|
0d20ef |
|