xfs
[Top] [All Lists]

[PATCH 02/15] mkfs: sanitise ftype parameter values.

To: xfs@xxxxxxxxxxx
Subject: [PATCH 02/15] mkfs: sanitise ftype parameter values.
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Fri, 29 Nov 2013 12:43:37 +1100
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1385689430-10103-1-git-send-email-david@xxxxxxxxxxxxx>
References: <1385689430-10103-1-git-send-email-david@xxxxxxxxxxxxx>
From: Dave Chinner <dchinner@xxxxxxxxxx>

Because passing "-n ftype=2" should fail.

Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
---
 mkfs/xfs_mkfs.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index cc74535..3145205 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1550,12 +1550,15 @@ _("cannot specify both crc and ftype\n"));
                                                reqval('n', nopts, N_FTYPE);
                                        if (nftype)
                                                respec('n', nopts, N_FTYPE);
-                                       dirftype = atoi(value);
+                                       c = atoi(value);
+                                       if (c < 0 || c > 1)
+                                               illegal(value, "n ftype");
                                        if (crcs_enabled) {
                                                fprintf(stderr,
 _("cannot specify both crc and ftype\n"));
                                                usage();
                                        }
+                                       dirftype = c;
                                        nftype = 1;
                                        break;
                                default:
-- 
1.8.4.rc3

<Prev in Thread] Current Thread [Next in Thread>