]> git.ipfire.org Git - thirdparty/grub.git/commit
util/grub-install-common: Confirm directory creation in grub_install_mkdir_p()
authorDarren Kenny <darren.kenny@oracle.com>
Tue, 9 Aug 2022 13:29:05 +0000 (13:29 +0000)
committerDaniel Kiper <daniel.kiper@oracle.com>
Fri, 19 Aug 2022 19:41:51 +0000 (21:41 +0200)
commit2669f9864341d861364084f5a976117aad2bd8f5
treef9440ad73715f8343a7164d995ae8399b39a4eff
parentd22cbe0decf54c6a248250b869ddb169babceb60
util/grub-install-common: Confirm directory creation in grub_install_mkdir_p()

Because grub_util_mkdir() is implemented to not return a value on any
platform, grub_instal_mkdir_p() can test for success by confirming that
the directory requested exists after attempting to create it, otherwise
it should fail with an error and exit.

While fixing this, a flaw in the logic was shown, where the first match
of the path separator, which almost always was the first character in
the path (e.g. /boot/grub2) would result in creating a directory with an
empty name (i.e. ""). To avoid that, it should skip the handling of the
path separator where p is pointing to the first character.

Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
util/grub-install-common.c