[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 0/2] util: Resolve issues with use of grub_util_mkdir

From: Darren Kenny
Subject: [PATCH 0/2] util: Resolve issues with use of grub_util_mkdir
Date: Tue, 9 Aug 2022 13:29:03 +0000

Coverity flagged some issues where grub_util_mkdir() was being called but the
return value was not being checked.

After examining the implementation, on UNIX and ACROS, grub_util_mkdir() is a
macro that maps to libc's mkdir(), which returns an int.

But on MS Windows, grub_util_mkdir() is a function with a void return, and
which in turn eventually maps to the MS API CreateDirectory() call.

After discussing with Daniel, it was felt that fixing this by reimplementing
the Windows code for grub_util_mkdir() to return something like the
libc equivalents. This and then testing the return values on each call to
grub_util_mkdir() in the util code is of little benefit when the main usage is
to populate a temporary directory that was created earlier in the code of
grub-mkrescue, which should never fail.

The solution presented in patch 1, to resolve Coverity's concerns is to cast
the return value of the mkdir() command to void in the macro for

The other use-case is in the grub_util_mkdir_p() function that creates
a directory tree, as the UNIX command mkdir -p does. This code should at least
try confirm that it is successfully creating the parent directories before it
continues to the sub-directories. This is done by using
grub_util_is_directory() to ensure that the directory exists, and if it
doesn't then to call grub_util_error() with some information and exit.

In fixing this, it was discovered that grub_util_mkdir() was incorrectly being
called with an empty directory name (""), which was due to an error in the
tokenisation being performed.

Darren Kenny (2):
  util: Ignore return value for grub_util_mkdir() on all platforms
  util: confirm directory creation in grub_install_mkdir_p

 include/grub/osdep/hostfile_aros.h | 2 +-
 include/grub/osdep/hostfile_unix.h | 2 +-
 util/grub-install-common.c         | 7 ++++++-
 3 files changed, 8 insertions(+), 3 deletions(-)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]