aboutsummaryrefslogtreecommitdiff
path: root/tools/env
diff options
context:
space:
mode:
authorAndreas Fenkart <andreas.fenkart@digitalstrom.com>2015-12-09 13:13:21 +0100
committerTom Rini <trini@konsulko.com>2016-02-08 10:10:29 -0500
commit167f52587173ad87aac7780058d59aa96422eed0 (patch)
treed39de91480d87b075fec417430042ffff6be2823 /tools/env
parent57dc53a72460e8e301fa1cc7951b41db8e731485 (diff)
downloadu-boot-167f52587173ad87aac7780058d59aa96422eed0.zip
u-boot-167f52587173ad87aac7780058d59aa96422eed0.tar.gz
u-boot-167f52587173ad87aac7780058d59aa96422eed0.tar.bz2
tools: env validate: pass values as 0-based array
passing argv/argc can produce off-by-one errors Signed-off-by: Andreas Fenkart <andreas.fenkart@digitalstrom.com>
Diffstat (limited to 'tools/env')
-rw-r--r--tools/env/fw_env.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 39f7333..8c452a8 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -498,8 +498,9 @@ int fw_setenv(int argc, char *argv[])
{
int i, rc;
size_t len;
- char *name;
+ char *name, **valv;
char *value = NULL;
+ int valc;
#ifdef CONFIG_FILE
if (argc >= 2 && strcmp(argv[1], "-c") == 0) {
@@ -543,13 +544,15 @@ int fw_setenv(int argc, char *argv[])
}
name = argv[1];
+ valv = argv + 2;
+ valc = argc - 2;
- if (env_flags_validate_env_set_params(argc, argv) < 0)
+ if (env_flags_validate_env_set_params(name, valv, valc) < 0)
return 1;
len = 0;
- for (i = 2; i < argc; ++i) {
- char *val = argv[i];
+ for (i = 0; i < valc; ++i) {
+ char *val = valv[i];
size_t val_len = strlen(val);
if (value)