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

net/wget patch



wget segfaults or prints garbage for long urls / file names on macppc:

$ wget 'http://remix.kwed.org/download.php/719/CZ%20Tunes%20-%20Rock%27n%20Roll%20Level%201%20Remix%20%28Special%20CZ%20Tunes%20Remix%29.mp3'
--        --  (null)
  行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行CZ Tunes - Rock'n Roll Level 1 Remix (Special CZ Tunes Remix).mp3 => `'
Connecting to remix.kwed.org:80... connected!

malloc.conf is symlinked to J, so that's where the '' come from.

Turns out it does vsnprintf() on the same va_list multiple times in that
case, which macppc doesn't like.

The patch below works for me.

Daniel


--- src/log.c.orig	Sun May 27 21:35:05 2001
+++ src/log.c	Mon Feb  3 15:09:07 2003
@@ -310,7 +310,12 @@
              the systems where vsnprintf() is not available, we use
              the implementation from snprintf.c which does return the
              correct value.  */
-	  int numwritten = vsnprintf (write_ptr, available_size, fmt, args);
+	  va_list args2;
+	  int numwritten;
+
+	  va_copy(args2, args);
+	  numwritten = vsnprintf (write_ptr, available_size, fmt, args2);
+	  va_end(args2);
 
 	  /* vsnprintf() will not step over the limit given by
              available_size.  If it fails, it will return either -1