From 849488a953c0c98fbe5a473689bd25d5494b5927 Mon Sep 17 00:00:00 2001 From: "Alfred M. Szmidt" Date: Sun, 5 Dec 2004 14:29:43 +0000 Subject: 2004-09-08 Neal H. Walfield * linux/dev/kernel/printk.c: Include . (printk): Use vsnprintf, not linux_vsprintf to avoid buffer overruns. * kern/printf.c (struct vsnprintf_cookie): New structure. (snputc): New function. (vsnprintf): Likewise. --- linux/dev/kernel/printk.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'linux/dev/kernel') diff --git a/linux/dev/kernel/printk.c b/linux/dev/kernel/printk.c index 2ff52d1..9dc86cb 100644 --- a/linux/dev/kernel/printk.c +++ b/linux/dev/kernel/printk.c @@ -26,6 +26,7 @@ #define MACH_INCLUDE #include #include +#include static char buf[2048]; @@ -40,14 +41,14 @@ printk (char *fmt, ...) va_list args; int n, flags; extern void cnputc (); - extern int linux_vsprintf (char *buf, char *fmt,...); char *p, *msg, *buf_end; static int msg_level = -1; save_flags (flags); cli (); va_start (args, fmt); - n = linux_vsprintf (buf + 3, fmt, args); + n = vsnprintf (buf + 3, sizeof (buf) - 3, fmt, args); + assert (n <= sizeof (buf) - 3); buf_end = buf + 3 + n; va_end (args); for (p = buf + 3; p < buf_end; p++) -- cgit v1.2.3