summaryrefslogtreecommitdiff
path: root/linux
diff options
context:
space:
mode:
authorAlfred M. Szmidt <ams@gnu.org>2004-12-05 14:29:43 +0000
committerThomas Schwinge <tschwinge@gnu.org>2009-06-18 00:15:26 +0200
commit849488a953c0c98fbe5a473689bd25d5494b5927 (patch)
tree65c2a8097eb4987fdae9fe110486a66fb7d5ef56 /linux
parent2316d2aa6b9bbbe3f3ad7c604d0cc18000d47b81 (diff)
2004-09-08 Neal H. Walfield <neal@cs.uml.edu>
* linux/dev/kernel/printk.c: Include <kern/assert.h>. (printk): Use vsnprintf, not linux_vsprintf to avoid buffer overruns. * kern/printf.c (struct vsnprintf_cookie): New structure. (snputc): New function. (vsnprintf): Likewise.
Diffstat (limited to 'linux')
-rw-r--r--linux/dev/kernel/printk.c5
1 files changed, 3 insertions, 2 deletions
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 <stdarg.h>
#include <asm/system.h>
+#include <kern/assert.h>
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++)