* [PATCH] archelp: If path given to grub_archelp_dir is not a directory return error
@ 2023-08-14 6:03 Glenn Washburn
2023-08-14 14:07 ` Daniel Kiper
0 siblings, 1 reply; 2+ messages in thread
From: Glenn Washburn @ 2023-08-14 6:03 UTC (permalink / raw)
To: grub-devel, Daniel Kiper, Vladimir 'phcoder' Serbinenko
Cc: Glenn Washburn
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] archelp: If path given to grub_archelp_dir is not a directory return error
2023-08-14 6:03 [PATCH] archelp: If path given to grub_archelp_dir is not a directory return error Glenn Washburn
@ 2023-08-14 14:07 ` Daniel Kiper
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Kiper @ 2023-08-14 14:07 UTC (permalink / raw)
To: Glenn Washburn; +Cc: grub-devel, Vladimir 'phcoder' Serbinenko
On Mon, Aug 14, 2023 at 01:03:41AM -0500, Glenn Washburn wrote:
> 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>
Daniel
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-08-14 14:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-14 6:03 [PATCH] archelp: If path given to grub_archelp_dir is not a directory return error Glenn Washburn
2023-08-14 14:07 ` Daniel Kiper
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.