mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <>
To: Barebox List <>
Subject: [PATCH] lib: parameter: Do not modify pointer returned from xstrdup()
Date: Thu, 16 Jun 2022 15:47:30 +0200	[thread overview]
Message-ID: <> (raw)

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 <>
 lib/parameter.c | 4 ++--
 1 file 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)

                 reply	other threads:[~2022-06-16 13:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox