save_env prepends \0 to grubenv, causing "error: invalid environment block."

Bug #1876319 reported by Clara Short
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
grub2 (Ubuntu)
New
Undecided
Unassigned

Bug Description

Reported upstream as https://savannah.gnu.org/bugs/index.php?58283 .

= Configuration =
grub> echo $package_version $grub_cpu $grub_platform
2.02-2ubuntu8.15 i386 pc

== 1. Initial conditions ==
# rm /boot/grub/grubenv
# grub-editenv - create
# grub-editenv - set foo=bar
# grub-editenv - list
foo=bar
# hexdump -C /boot/grub/grubenv
00000000 23 20 47 52 55 42 20 45 6e 76 69 72 6f 6e 6d 65 |# GRUB Environme|
00000010 6e 74 20 42 6c 6f 63 6b 0a 66 6f 6f 3d 62 61 72 |nt Block.foo=bar|
00000020 0a 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 |.###############|
00000030 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 |################|
*
00000400
# reboot

== 2. Drop to GRUB shell ==
grub> list_env
foo=bar
grub> baz=quux
grub> save_env baz
grub> list_env
error: invalid environment block.
grub> reboot

== 3. Boot into Linux ==
$ grub-editenv - list
grub-editenv: error: invalid environment block.
$ hexdump -C /boot/grub/grubenv
00000000 00 23 20 47 52 55 42 20 45 6e 76 69 72 6f 6e 6d |.# GRUB Environm|
00000010 65 6e 74 20 42 6c 6f 63 6b 0a 66 6f 6f 3d 62 61 |ent Block.foo=ba|
00000020 72 0a 62 61 7a 3d 71 75 75 78 0a 23 23 23 23 23 |r.baz=quux.#####|
00000030 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 |################|
*
00000400
$

ProblemType: Bug
DistroRelease: Ubuntu 18.04
Package: grub-common 2.02-2ubuntu8.15
ProcVersionSignature: Ubuntu 4.15.0-99.100-generic 4.15.18
Uname: Linux 4.15.0-99-generic x86_64
ApportVersion: 2.20.9-0ubuntu7.14
Architecture: amd64
CurrentDesktop: XFCE
Date: Fri May 1 10:35:28 2020
SourcePackage: grub2
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Clara Short (mx-clarity) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.