All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maxime Larocque <maxmtl2002@yahoo.ca>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] printenv show garbage on out-of-memory conditions
Date: Fri, 28 Sep 2012 11:00:13 -0400	[thread overview]
Message-ID: <5065BB7D.3010806@yahoo.ca> (raw)

Hello,

In common/cmd_nvedit.c, en env_print(), the wrong type is used for len. hexport_r() returns -1 on error (like OOM), which is converted to 0xffffffff when put in an unsigned. Said value is obviously bigger then 0, and as a result an uninitialized string is then displayed. Other usages of hexport_r() in the code correctly uses ssize_t to keep its return value.

Does not seem to be critical, but it is misleading when debugging a OOM error...

I have added a printf to display something in case of error; I'll leave it to the committer to keep it or remove it.

Found in U-Boot 2011.12, but still present in current git.

Maxime Larocque

Signed-off-by: Maxime Larocque <maxmtl2002@yahoo.ca>
--- common/cmd_nvedit.c
+++ common/cmd_nvedit.c
@@ -110,7 +110,7 @@
  static int env_print(char *name)
  {
  	char *res = NULL;
-	size_t len;
+	ssize_t len;
  
  	if (name) {		/* print a single name */
  		ENTRY e, *ep;
@@ -132,6 +132,9 @@
  		free(res);
  		return len;
  	}
+	else {
+		printf("## Error: cannot export environment\n");
+	}
  
  	/* should never happen */
  	return 0;

             reply	other threads:[~2012-09-28 15:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-28 15:00 Maxime Larocque [this message]
2013-04-17 15:36 ` [U-Boot] printenv show garbage on out-of-memory conditions Tom Rini

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=5065BB7D.3010806@yahoo.ca \
    --to=maxmtl2002@yahoo.ca \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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 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.