diff options
author | Glenn Washburn <development@efficientek.com> | 2023-08-14 01:03:41 -0500 |
---|---|---|
committer | Daniel Kiper <daniel.kiper@oracle.com> | 2023-08-14 18:07:24 +0200 |
commit | fcbea18c584257adc824cbb1c66cec2f4329869c (patch) | |
tree | 86711c7cb2d4ea3e05a5e29183241a89b1a9266d | |
parent | 1de58326994b0045ccfb28017d05fc1ddecdb92d (diff) |
fs/archelp: If path given to grub_archelp_dir() is not a directory return error
Specifically, return GRUB_ERR_BAD_FILE_TYPE because this is what is
expected by the ls command when it is given a path to a non-directory.
This fixes a bug where calling ls with a list of non-directory paths
outputs a blank line for each such argument.
Signed-off-by: Glenn Washburn <development@efficientek.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
-rw-r--r-- | grub-core/fs/archelp.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/grub-core/fs/archelp.c b/grub-core/fs/archelp.c index 998de88b8..c1dcc6285 100644 --- a/grub-core/fs/archelp.c +++ b/grub-core/fs/archelp.c @@ -180,6 +180,14 @@ grub_archelp_dir (struct grub_archelp_data *data, if (p) *p = 0; + if ((*n == 0) && ((mode & GRUB_ARCHELP_ATTR_TYPE) + != GRUB_ARCHELP_ATTR_DIR)) + { + grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory")); + grub_free (name); + goto fail; + } + if (((!prev) || (grub_strcmp (prev, name) != 0)) && *n != 0) { struct grub_dirhook_info info; |