mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-27 07:51:38 +00:00
tiny-printf: Handle NULL pointer argument to %s
A NULL pointer argument to %s causes a NULL pointer dereference in the fixed width numerical printout code, since p is overwritten with NULL. In case of %s width is 0. Check width before dereferencing the pointer. Signed-off-by: Benedikt Spranger <b.spranger@linutronix.de> Reviewed-by: John Ogness <john.ogness@linutronix.de>
This commit is contained in:
parent
62224280d9
commit
f0dab28915
1 changed files with 1 additions and 1 deletions
|
@ -312,7 +312,7 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
|
||||||
|
|
||||||
*info->bf = 0;
|
*info->bf = 0;
|
||||||
info->bf = p;
|
info->bf = p;
|
||||||
while (*info->bf++ && width > 0)
|
while (width > 0 && info->bf && *info->bf++)
|
||||||
width--;
|
width--;
|
||||||
while (width-- > 0)
|
while (width-- > 0)
|
||||||
info->putc(info, lz ? '0' : ' ');
|
info->putc(info, lz ? '0' : ' ');
|
||||||
|
|
Loading…
Add table
Reference in a new issue