Bug#285872: update-grub script should check for infinite loops.

Carlos O'Donell Carlos O'Donell <carlos@baldric.uwo.ca>, 285872@bugs.debian.org
Wed, 15 Dec 2004 21:51:30 -0500


Package: grub
Version: 0.95+cvs20040624-12

If update-grub is invoked with a kernel that contains no numeric
component, but instead a string identifier, then the get_kernel_opt()
function will loop forever.

A fix is attached to make the script more robust, this was tested
with a kernel named "vmlinuz-test" and passes. Under the previous
script the script would hang forever.

The change checks to see if the string changed between the call to sed.
If the string is the same then the sed script hasn't changed the input
and the loop will run forver, so instead we terminate.

--- /sbin/update-grub	2004-11-22 18:05:11.000000000 -0500
+++ /root/update-grub	2004-12-15 21:38:10.000000000 -0500
@@ -500,7 +500,11 @@
 			if [ -n "$currentOpt" ] ; then
 				break
 			fi
-			version=$(echo $version | sed 's/_\?[0-9]*$//')
+			version_temp=$(echo $version | sed 's/_\?[0-9]*$//')
+			if [ "$version" = "$version_temp" ] ; then
+				# No change in the string, can't parse!
+				break
+			fi
 		done
 	fi
 
Please apply.

Cheers,
Carlos O'Donell.