xfs
[Top] [All Lists]

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

To: xfs@xxxxxxxxxxx
Subject: [PATCH 02/19] mkfs: sanitise ftype parameter values.
From: Jan Tulak <jtulak@xxxxxxxxxx>
Date: Thu, 21 Apr 2016 11:39:36 +0200
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1461231593-31294-1-git-send-email-jtulak@xxxxxxxxxx>
References: <1461231593-31294-1-git-send-email-jtulak@xxxxxxxxxx>
From: Dave Chinner <dchinner@xxxxxxxxxx>

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

Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
Signed-off-by: Jan Tulak <jtulak@xxxxxxxxxx>

---
UPDATE:
* Remove a check for crc enabled with ftype - there is another one later on.
  As it was in the ftype handling, it failed if -m crc=0 was after ftype.
---
 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 5527b87..4be14da 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1597,7 +1597,10 @@ main(
                                                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");
+                                       dirftype = c;
                                        nftype = 1;
                                        break;
                                default:
-- 
2.5.0

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