Skip to contentSkip to conversation

m68k: sun3: Replace vsprintf() with bounded vsnprintf()

PATCH In review Thorsten Blum 2 participants 2 messages Jan 17 – Jan 26

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 m68k: sun3: Replace vsprintf() with bounded vsnprintf()

vsprintf() performs no bounds checking and can overflow - replace it with the safer vsnprintf().

Also remove the useless '+ 1' that is a leftover of commit 66ed28ea096c ("m68k: sun3: Remove unused vsprintf() return value in prom_printf()").

---
Compile-tested only.

---
 arch/m68k/sun3/prom/printf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/m68k/sun3/prom/printf.c +2 -2
index db5537ef1250..cb4934d39833 100644
@@ -30,9 +30,9 @@ prom_printf(char *fmt, ...)
 
 #ifdef CONFIG_KGDB
 	ppbuf[0] = 'O';
-	vsprintf(ppbuf + 1, fmt, args) + 1;
+	vsnprintf(ppbuf + 1, sizeof(ppbuf) - 1, fmt, args);
 #else
-	vsprintf(ppbuf, fmt, args);
+	vsnprintf(ppbuf, sizeof(ppbuf), fmt, args);
 #endif
 
 	bptr = ppbuf;
Signature · 2 lines
Thorsten Blum <[email protected]>
GPG: 1D60 735E 8AEF 3BE4 73B6  9D84 7336 78FD 8DFE EAD4
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Thorsten Blum

vsprintf() performs no bounds checking and can overflow - replace it with the safer vsnprintf().

Also remove the useless '+ 1' that is a leftover of commit 66ed28ea096c ("m68k: sun3: Remove unused vsprintf() return value in prom_printf()").

i.e. will queue in the m68k tree for v6.20.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds