All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][pseudo 1/7] pseudo_util: don't overrun strings when looking for keys
@ 2021-01-08 14:06 Ross Burton
  2021-01-08 14:06 ` [PATCH][pseudo 2/7] Silence switch block warnings Ross Burton
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Ross Burton @ 2021-01-08 14:06 UTC (permalink / raw)
  To: openembedded-core

Use strcmp() insead of memcmp() when searching for keys as otherwise
the comparison will run off the end of the NULL-terminated string.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 pseudo_util.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pseudo_util.c b/pseudo_util.c
index 1d06009..51c07c2 100644
--- a/pseudo_util.c
+++ b/pseudo_util.c
@@ -159,7 +159,7 @@ pseudo_get_value(const char *key) {
 	if (pseudo_util_initted == -1)
 		pseudo_init_util();
 
-	for (i = 0; pseudo_env[i].key && memcmp(pseudo_env[i].key, key, pseudo_env[i].key_len + 1); i++)
+	for (i = 0; pseudo_env[i].key && strcmp(pseudo_env[i].key, key); i++)
 		;
 
 	/* Check if the environment has it and we don't ...
@@ -188,7 +188,7 @@ pseudo_set_value(const char *key, const char *value) {
 	if (pseudo_util_initted == -1)
 		pseudo_init_util();
 
-	for (i = 0; pseudo_env[i].key && memcmp(pseudo_env[i].key, key, pseudo_env[i].key_len + 1); i++)
+	for (i = 0; pseudo_env[i].key && strcmp(pseudo_env[i].key, key); i++)
 		;
 
 	if (pseudo_env[i].key) {
-- 
2.25.1


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

end of thread, other threads:[~2021-01-08 16:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-08 14:06 [PATCH][pseudo 1/7] pseudo_util: don't overrun strings when looking for keys Ross Burton
2021-01-08 14:06 ` [PATCH][pseudo 2/7] Silence switch block warnings Ross Burton
2021-01-08 14:06 ` [PATCH][pseudo 3/7] Disable deprecated function warnings Ross Burton
2021-01-08 14:06 ` [PATCH][pseudo 4/7] Fix some memory leaks Ross Burton
2021-01-08 16:01   ` [OE-core] " Seebs
2021-01-08 14:06 ` [PATCH][pseudo 5/7] makewrappers: fix Python 2 hangover Ross Burton
2021-01-08 14:06 ` [PATCH][pseudo 6/7] makewrappers: support architecture-overrides in wrapper modifiers Ross Burton
2021-01-08 14:06 ` [PATCH][pseudo 7/7] ports/linux/xattr: add arm64 versions for xattr calls Ross Burton

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.