Re: [PATCH] common: misc: support strerror(err) for all err <= MAX_ERRNO

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
> ---
> 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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux