aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@arm.com>2021-01-05 15:36:43 +0000
committerRoss Burton <ross.burton@arm.com>2021-01-08 13:14:01 +0000
commitaa1a3d74d1ae1f322022df4c67ea71c01848fb12 (patch)
tree24d22e4555bcdc9aeeffadd388c2c776ce43f064
parent1ee9a1e05e200f189f6644411ba9304e8a479b0b (diff)
downloadpseudo-aa1a3d74d1ae1f322022df4c67ea71c01848fb12.tar.gz
pseudo-aa1a3d74d1ae1f322022df4c67ea71c01848fb12.tar.bz2
pseudo-aa1a3d74d1ae1f322022df4c67ea71c01848fb12.zip
pseudo_util: don't overrun strings when looking for keys
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>
-rw-r--r--pseudo_util.c4
1 files 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) {