summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2022-06-16 15:41:23 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-06-16 15:47:22 +0200
commit62074ec3867d8fe6b2e8d1989ae0f547692be727 (patch)
treeb74956924cf5ca1ca3207294e0b2c546fbebc224 /lib
parenta06613b45a550712bb65483668bac224895732ec (diff)
downloadbarebox-62074ec3867d8fe6b2e8d1989ae0f547692be727.tar.gz
barebox-62074ec3867d8fe6b2e8d1989ae0f547692be727.tar.xz
lib: parameter: Do not modify pointer returned from xstrdup()
The sequence value_new = xstrdup(val); value_new = strim(value_new) is buggy because we not free the pointer we originally allocated. Fix this by skipping the leading whitespaces from the original string. The bug itself never triggered because the string is never freed. That will be fixed in the next patch. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/parameter.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/parameter.c b/lib/parameter.c
index adc3c7cdea..2c9da870a4 100644
--- a/lib/parameter.c
+++ b/lib/parameter.c
@@ -258,8 +258,8 @@ static int param_string_set(struct device_d *dev, struct param_d *p, const char
if (!val)
val = "";
- value_new = xstrdup(val);
- value_new = strim(value_new);
+ value_new = xstrdup(skip_spaces(val));
+ strim(value_new);
*ps->value = value_new;
if (!ps->set)