xfs
[Top] [All Lists]

[PATCH] xfstests: check for valid input to _scratch_mkfs_sized

To: xfs-oss <xfs@xxxxxxxxxxx>
Subject: [PATCH] xfstests: check for valid input to _scratch_mkfs_sized
From: Eric Sandeen <sandeen@xxxxxxxxxx>
Date: Tue, 17 Sep 2013 14:30:41 -0500
Delivered-to: xfs@xxxxxxxxxxx
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130801 Thunderbird/17.0.8
_scratch_mkfs_sized requires an integer number of bytes
as input; if it's given something else, catch it and _notrun.

Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
---

diff --git a/common/rc b/common/rc
index 77e96c4..6afc164 100644
--- a/common/rc
+++ b/common/rc
@@ -569,6 +569,15 @@ _scratch_mkfs_sized()
     fssize=$1
     blocksize=$2
     [ -z "$blocksize" ] && blocksize=4096
+
+    re='^[0-9]+$'
+    if ! [[ $fssize =~ $re ]] ; then
+        _notrun "error: _scratch_mkfs_sized: fs size \"$fssize\" not an 
integer."
+    fi
+    if ! [[ $blocksize =~ $re ]] ; then
+        _notrun "error: _scratch_mkfs_sized: block size \"$blocksize\" not an 
integer."
+    fi
+
     blocks=`expr $fssize / $blocksize`
 
     if [ "$HOSTOS" == "Linux" ]; then


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