mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Ahmad Fatoum <ahmad@a3f.at>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] common: misc: support strerror(err) for all err <= MAX_ERRNO
Date: Mon, 28 Sep 2020 10:28:31 +0200	[thread overview]
Message-ID: <20200928082831.GE11648@pengutronix.de> (raw)
In-Reply-To: <20200921071135.561256-1-ahmad@a3f.at>

On Mon, Sep 21, 2020 at 09:11:35AM +0200, Ahmad Fatoum wrote:
> We have a _LAST_ERRNO of 3 decimal digits. strerror(_LAST_ERRNO) is ok,
> but it's still possible that some code passes a non-error code int,
> which will overflow the static buffer. Play it safe and bump up the
> buffer size to at least 11 characters. This is enough to represent
> all integers, with only 7 characters more static storage.
> 
> This way strerror(some_int_passed_by_mistake) will not invoke UB.
> 
> Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
> ---
> Detected by ASAN on sandbox a while ago. The place which passed the
> non-errno int needs probably fixing as well, but I need to find it again
> first..
> ---
>  common/misc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Applied, thanks

Sascha


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      reply	other threads:[~2020-09-28  8:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-21  7:11 Ahmad Fatoum
2020-09-28  8:28 ` Sascha Hauer [this message]

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=20200928082831.GE11648@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=ahmad@a3f.at \
    --cc=barebox@lists.infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox