All of lore.kernel.org
 help / color / mirror / Atom feed
* [pseudo] [PATCH 1/7] pseudo.h: Avoid accessing unallocated memory
@ 2026-07-01 13:13 Richard Purdie
  2026-07-01 13:13 ` [pseudo] [PATCH 2/7] pseudo_util: Avoid accidental free calls for without_libpseudo() Richard Purdie
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Richard Purdie @ 2026-07-01 13:13 UTC (permalink / raw)
  To: yocto-patches; +Cc: seebs, mark.hatle

We can call STARTSWITH in cases where the item being searched for is longer
than the string itself. Switch from memcmp to strncmp to avoid accessing
unassigned memory.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 pseudo.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pseudo.h b/pseudo.h
index b6c13f2..1152c19 100644
--- a/pseudo.h
+++ b/pseudo.h
@@ -99,7 +99,7 @@ extern char *pseudo_version;
  #define PSEUDO_LIBDIR "lib"
 #endif
 
-#define STARTSWITH(x, y) (!memcmp((x), (y), sizeof(y) - 1))
+#define STARTSWITH(x, y) (strncmp(y, x, strlen(y)) == 0)
 
 #ifndef PSEUDO_LOCALSTATEDIR
  #define PSEUDO_LOCALSTATEDIR "var/pseudo"


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

end of thread, other threads:[~2026-07-02  6:24 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-01 13:13 [pseudo] [PATCH 1/7] pseudo.h: Avoid accessing unallocated memory Richard Purdie
2026-07-01 13:13 ` [pseudo] [PATCH 2/7] pseudo_util: Avoid accidental free calls for without_libpseudo() Richard Purdie
2026-07-01 13:13 ` [pseudo] [PATCH 3/7] pseudo_util: Ensure pseudo_setupenvp handles memory consistently Richard Purdie
2026-07-01 13:13 ` [pseudo] [PATCH 4/7] pseudo_util: Avoid a memory leak in pseudo_dropenv() Richard Purdie
2026-07-01 13:13 ` [pseudo] [PATCH 5/7] pseudo_util: Clean up memory handling for setupenvp results Richard Purdie
2026-07-01 13:13 ` [pseudo] [PATCH 6/7] exec*: Replace bash workaround to avoid memory corruption Richard Purdie
2026-07-02  5:54   ` [yocto-patches] " Gaël PORTAY
2026-07-02  6:23     ` Richard Purdie
2026-07-01 13:13 ` [pseudo] [PATCH 7/7] pseudo_util: Correctly free memory allocated by pseudo_setupenvp Richard Purdie
2026-07-01 16:40 ` [pseudo] [PATCH 1/7] pseudo.h: Avoid accessing unallocated memory Mark Hatle
2026-07-01 16:47   ` Richard Purdie
2026-07-01 18:59     ` [yocto-patches] " Mark Hatle

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.