40grub2 incorrectly extracts title from grub.cfg entries that contain more than two single quotes
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
os-prober (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
When linux-boot-prober (from os-prober 1.51ubuntu3 on Ubuntu 12.04.3) finds a grub.cfg containing a line like
menuentry 'Gentoo GNU/Linux, with Linux x86_64-
and runs /linux-
/dev/sda4:
where
Gentoo GNU/Linux, with Linux x86_64-
is the title (which should just be "Gentoo GNU/Linux, with Linux x86_64-
Apparently, the regex used by 40grub2 is too greedy and matches everything between the two outermost single quotes, instead of the first two. The same will probably happen with entries where the title is enclosed in double quotes and more than two of those are present, but I haven't observed it yet.
I have attached a patch for 40grub2 that modifies the regex to stop at the first occurence of a single quote for titles enclosed in single quotes and the first double quote for titles enclosed in double quotes.
Note that this might fail in the rare case of someone using escaped quotes in their GRUB menuentry titles (although I'm not entirely sure if that's even supported).
Apparently, this issue was fixed in revision 30 (i.e. 1.56ubuntu1): http:// bazaar. launchpad. net/~ubuntu- branches/ ubuntu/ trusty/ os-prober/ trusty/ revision/ 30#linux- boot-probes/ mounted/ common/ 40grub2