[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

vfprintf.c bugfix



Ethan,

The good news is that I now know a little more about powerpc assembly.
The bad news is that the problem was not in the varargs implementation, but 
its use.

You used to call vsnprintf twice.  Once to find out how much buffer would be 
needed, then the second time for real. You can't do that without reseting ap.

The appended patch proposes a fix.
Btw: You said you'd tested that with LD_PRELOAD? What happend?

--- /tmp/yaboot-1.99.x/lib/libc/stdio/vfprintf.c	2003-03-08 22:57:36.000000000 
-0800
+++ stdio/vfprintf.c	2003-07-10 16:43:20.000000000 -0700
@@ -30,10 +30,9 @@
      int ret;
      int sz;
 
-     if ((sz = vsnprintf(NULL, 0, fmt, ap)) < BUFSZ) {
-	  char buf[BUFSZ];
+     char buf[BUFSZ];
 
-	  sz = vsnprintf(buf, sizeof buf, fmt, ap);
+     if ((sz = vsnprintf(buf, BUFSZ, fmt, ap)) < BUFSZ) {
 
 	  if (sz <= 0)
 	       return sz;


-- 
Remco Treffkorn (RT445)
HAM DC2XT
remco@rvt.com   (831) 685-1201