[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#697017: root=compute fails at parse_numeric() for lilo compatibility



Hi,

Stephen Powell wrote:

> The pattern in question, [A-Fa-f0-9]*, will match any string of characters of
> arbitrary length (at least one character long) whose first character is a
> valid hex digit (0-9, a-f, or A-F).  Remember, this is a shell pattern, not
> a regular expression.

How about this patch?

 scripts/functions | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/scripts/functions b/scripts/functions
index 6e74adec..c1d19452 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -267,24 +267,27 @@ load_modules()
 # lilo compatibility
 parse_numeric() {
 	case $1 in
-	"")
-		return
-		;;
-	/*)
-		return
-		;;
-	[0-9]*:[0-9]*)
+	*:*)
+		# Does it match /[0-9]*:[0-9]*/?
 		minor=$(( ${1#*:} ))
 		major=$(( ${1%:*} ))
+		case $major$minor in
+		*[!0-9]*)
+			# No.
+			return
+			;;
+		esac
 		;;
-	[A-Fa-f0-9]*)
+	*[!A-Fa-f0-9]*)
+		# "", "/*", etc.
+		return
+		;;
+	*)
+		# [A-Fa-f0-9]*
 		value=$(( 0x${1} ))
 		minor=$(( ${value} % 256 ))
 		major=$(( ${value} / 256 ))
 		;;
-	*)
-		return
-		;;
 	esac
 
 	if command -v udevd >/dev/null 2>&1; then
-- 
1.8.1.rc3


Reply to: