util: Resolve issues with use of grub_util_mkdir
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest2 patches 3 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | util: Ignore return value for grub_util_mkdir() on all platformsinclude/ include/ | +2 | 0 replies | |
| 2/2 | util: confirm directory creation in grub_install_mkdir_putil/ | +6 | 2 replies |
Reviews trailers per patch
None of the 2 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.
| Patch | Daniel Kiper |
|---|---|
| Series | R-b |
| 1/2 | |
| 2/2 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH 0/2] util: Resolve issues with use of grub_util_mkdir
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(-)
Signature · 1 line
2.31.1