linux-mips
[Top] [All Lists]

[PATCH]: fix possible buffer overflow problem in promlib

To: Ralf Baechle <ralf@linux-mips.org>, mipslist <linux-mips@linux-mips.org>
Subject: [PATCH]: fix possible buffer overflow problem in promlib
From: Juan Quintela <quintela@mandrakesoft.com>
Date: 02 Jan 2003 20:33:30 +0100
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
Hi
        as the issue about prom.h is still not clear, please aply the
        trivial part.

        32 and 64 bits patch.

Later, Juan.

Index: arch/mips64/lib/promlib.c
===================================================================
RCS file: /home/cvs/linux/arch/mips64/lib/promlib.c,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 promlib.c
--- arch/mips64/lib/promlib.c   28 Sep 2002 22:28:38 -0000      1.1.2.1
+++ arch/mips64/lib/promlib.c   20 Dec 2002 19:10:45 -0000
@@ -1,13 +1,19 @@
+
+
+#include <linux/kernel.h>
+
 #include <stdarg.h>
 
+#define BUFSIZE 1024
+
 void prom_printf(char *fmt, ...)
 {
        va_list args;
-       char ppbuf[1024];
+       char ppbuf[BUFSIZE];
        char *bptr;
 
        va_start(args, fmt);
-       vsprintf(ppbuf, fmt, args);
+       vsnprintf(ppbuf, BUFSIZE, fmt, args);
 
        bptr = ppbuf;
 
Index: arch/mips/lib/promlib.c
===================================================================
RCS file: /home/cvs/linux/arch/mips/lib/promlib.c,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 promlib.c
--- arch/mips/lib/promlib.c     28 Sep 2002 22:28:38 -0000      1.1.2.1
+++ arch/mips/lib/promlib.c     20 Dec 2002 19:10:43 -0000
@@ -1,13 +1,19 @@
+
+
+#include <linux/kernel.h>
+
 #include <stdarg.h>
 
+#define BUFSIZE 1024
+
 void prom_printf(char *fmt, ...)
 {
        va_list args;
-       char ppbuf[1024];
+       char ppbuf[BUFSIZE];
        char *bptr;
 
        va_start(args, fmt);
-       vsprintf(ppbuf, fmt, args);
+       vsnprintf(ppbuf, BUFSIZE, fmt, args);
 
        bptr = ppbuf;
 


-- 
In theory, practice and theory are the same, but in practice they 
are different -- Larry McVoy

<Prev in Thread] Current Thread [Next in Thread>