All of lore.kernel.org
 help / color / mirror / Atom feed
From: Darren Kenny <darren.kenny@oracle.com>
To: grub-devel@gnu.org
Cc: daniel.kiper@oracle.com, darren.kenny@oracle.com
Subject: [PATCH 0/2] util: Resolve issues with use of grub_util_mkdir
Date: Tue,  9 Aug 2022 13:29:03 +0000	[thread overview]
Message-ID: <cover.1660050047.git.darren.kenny@oracle.com> (raw)

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
grub_util_mkdir().

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(-)

-- 
2.31.1



             reply	other threads:[~2022-08-09 13:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-09 13:29 Darren Kenny [this message]
2022-08-09 13:29 ` [PATCH 1/2] util: Ignore return value for grub_util_mkdir() on all platforms Darren Kenny
2022-08-09 13:29 ` [PATCH 2/2] util: confirm directory creation in grub_install_mkdir_p Darren Kenny
2022-08-09 14:04   ` Vladimir 'phcoder' Serbinenko
2022-08-09 15:34     ` Darren Kenny
2022-08-19 17:09 ` [PATCH 0/2] util: Resolve issues with use of grub_util_mkdir Daniel Kiper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1660050047.git.darren.kenny@oracle.com \
    --to=darren.kenny@oracle.com \
    --cc=daniel.kiper@oracle.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.