All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] loader/linux: Only emit newc directory once
@ 2023-06-28  7:25 Glenn Washburn
  2023-06-28 12:44 ` Daniel Kiper
  0 siblings, 1 reply; 2+ messages in thread
From: Glenn Washburn @ 2023-06-28  7:25 UTC (permalink / raw)
  To: grub-devel, Daniel Kiper; +Cc: Glenn Washburn

When creating at runtime a newc initrd via arguments to initrd with "newc:"
prefixes, only emit a directory path record once. The original code
intended to do that by bailing out of emiting the record when the record
to be created matches an existing record. However, this does not happen
because grub_memcmp() is improperly checked.

Generating duplicate newc directory records does not cause any problems
because the linux unpacker will skip it once it sees the directory already
exists. This fix saves a little processing and makes the generated newc
cpio archive a little smaller.

Fixes: 92750e4c60 (Add ability to generate newc additions on runtime.)
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
 grub-core/loader/linux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c
index 3948302d2c43..cb2c3f6e4f06 100644
--- a/grub-core/loader/linux.c
+++ b/grub-core/loader/linux.c
@@ -114,7 +114,7 @@ insert_dir (const char *name, struct dir **root,
 	break;
 
       for (cur = *root; cur; cur = cur->next)
-	if (grub_memcmp (cur->name, cb, ce - cb)
+	if (grub_memcmp (cur->name, cb, ce - cb) == 0
 	    && cur->name[ce - cb] == 0)
 	  break;
       if (!cur)
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] loader/linux: Only emit newc directory once
  2023-06-28  7:25 [PATCH] loader/linux: Only emit newc directory once Glenn Washburn
@ 2023-06-28 12:44 ` Daniel Kiper
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Kiper @ 2023-06-28 12:44 UTC (permalink / raw)
  To: Glenn Washburn; +Cc: grub-devel

On Wed, Jun 28, 2023 at 02:25:16AM -0500, Glenn Washburn wrote:
> When creating at runtime a newc initrd via arguments to initrd with "newc:"
> prefixes, only emit a directory path record once. The original code
> intended to do that by bailing out of emiting the record when the record
> to be created matches an existing record. However, this does not happen
> because grub_memcmp() is improperly checked.
>
> Generating duplicate newc directory records does not cause any problems
> because the linux unpacker will skip it once it sees the directory already
> exists. This fix saves a little processing and makes the generated newc
> cpio archive a little smaller.
>
> Fixes: 92750e4c60 (Add ability to generate newc additions on runtime.)
> Signed-off-by: Glenn Washburn <development@efficientek.com>

Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Daniel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-28 12:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-28  7:25 [PATCH] loader/linux: Only emit newc directory once Glenn Washburn
2023-06-28 12:44 ` 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.