diff --git a/ChangeLog b/ChangeLog index cce65e87f..0aae8dffc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2013-06-25 Colin Watson + + * util/grub-script-check.c: Fail on scripts containing no + commands, to guard against corrupted grub-mkconfig setups that + produce no useful output. + * tests/grub_script_no_commands.in: New test. + * Makefile.util.def (grub_script_no_commands): Add. + Reported by Hans Putter. Fixes Debian bug #713886. + 2013-06-16 Andrey Borzenkov * grub-core/disk/diskfilter.c: Forgot to remove comment diff --git a/Makefile.util.def b/Makefile.util.def index 97abd84c2..0b9f56ccc 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -748,6 +748,12 @@ script = { common = tests/grub_script_not.in; }; +script = { + testcase; + name = grub_script_no_commands; + common = tests/grub_script_no_commands.in; +}; + script = { testcase; name = partmap_test; diff --git a/tests/grub_script_no_commands.in b/tests/grub_script_no_commands.in new file mode 100644 index 000000000..c31d267e5 --- /dev/null +++ b/tests/grub_script_no_commands.in @@ -0,0 +1,21 @@ +#! /bin/sh +set -e + +# grub-script-check refuses to pass a file with no commands; this usually +# indicates a bug in the code generating that file. + +@builddir@/grub-script-check <cmd) + found_cmd = 1; grub_script_execute (script); grub_script_free (script); } @@ -202,6 +204,12 @@ main (int argc, char *argv[]) fprintf (stderr, _("Syntax error at line %u\n"), ctx.lineno); return 1; } + if (! found_cmd) + { + fprintf (stderr, _("Script contains no commands and will do nothing\n"), + ctx.arguments.filename); + return 1; + } return 0; }