All of lore.kernel.org
 help / color / mirror / Atom feed
From: Glenn Washburn <development@efficientek.com>
To: grub-devel@gnu.org, Daniel Kiper <dkiper@net-space.pl>,
	Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Cc: Glenn Washburn <development@efficientek.com>
Subject: [PATCH] archelp: If path given to grub_archelp_dir is not a directory return error
Date: Mon, 14 Aug 2023 01:03:41 -0500	[thread overview]
Message-ID: <20230814060341.1858840-1-development@efficientek.com> (raw)

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>
---
 grub-core/fs/archelp.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/grub-core/fs/archelp.c b/grub-core/fs/archelp.c
index 998de88b865c..c1dcc62858a9 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;
-- 
2.34.1


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

             reply	other threads:[~2023-08-14  6:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-14  6:03 Glenn Washburn [this message]
2023-08-14 14:07 ` [PATCH] archelp: If path given to grub_archelp_dir is not a directory return error 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=20230814060341.1858840-1-development@efficientek.com \
    --to=development@efficientek.com \
    --cc=dkiper@net-space.pl \
    --cc=grub-devel@gnu.org \
    --cc=phcoder@gmail.com \
    /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.