texlive-bin (2009-8) upstream-tex-file_arg-passing-fix

Summary

 texk/kpathsea/tex-file.c |   21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

    
download this patch

Patch contents

Fix for Debian bug 602566
patch by Mathias Kende include upstream
> The bug seems to come from libkpathsea5 and not from dvi2ps. It exists
> on all platforms (at least also on AMD64) but does not trigger a
> segfault. It comes from the kpse_set_suffixes function in the
> libkpathsea compatibility API which calls the kpathsea_set_suffixes
> function and passes to it its variable list of arguments. This operation
> is invalid in C.
---
 texk/kpathsea/tex-file.c |   21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

Index: texlive-bin-2009/texk/kpathsea/tex-file.c
===================================================================
--- texlive-bin-2009.orig/texk/kpathsea/tex-file.c	2010-11-10 10:56:14.000000000 +0900
+++ texlive-bin-2009/texk/kpathsea/tex-file.c	2010-11-10 10:56:28.000000000 +0900
@@ -321,14 +321,13 @@
 /* Some file types have more than one suffix, and sometimes it is
    convenient to modify the list of searched suffixes.  */ 
 
-void
-kpathsea_set_suffixes (kpathsea kpse, kpse_file_format_type format,
-  boolean alternate, ...)
+static void
+kpathsea_set_suffixes_va_list(kpathsea kpse, kpse_file_format_type format,
+  boolean alternate, va_list ap)
 {
   const_string **list;
   const_string s;
   int count = 0;
-  va_list ap;
 
   if (alternate) {
       list = &(kpse->format_info[format].alt_suffix);
@@ -336,16 +335,24 @@
       list = &(kpse->format_info[format].suffix);
   }
 
-  va_start (ap, alternate);
   while ((s = va_arg (ap, string)) != NULL) {
     count++;
     XRETALLOC (*list, count + 1, const_string);
     (*list)[count - 1] = s;
   }
-  va_end (ap);
   (*list)[count] = NULL;
 }
 
+void
+kpathsea_set_suffixes (kpathsea kpse, kpse_file_format_type format,
+  boolean alternate, ...)
+{
+  va_list ap;
+  va_start (ap, alternate);
+  kpathsea_set_suffixes_va_list (kpse, format, alternate, ap);
+  va_end (ap);
+}
+
 
 #if defined (KPSE_COMPAT_API)
 void
@@ -354,7 +361,7 @@
 {
   va_list ap;
   va_start (ap, alternate);
-  kpathsea_set_suffixes (kpse_def, format, alternate, ap);
+  kpathsea_set_suffixes_va_list (kpse_def, format, alternate, ap);
   va_end (ap);
 }
 #endif