View | Details | Raw Unified | Return to bug 203326 | Differences between
and this patch

Collapse All | Expand All

(-)files/patch-contrib-emacs-Makefile.in (-5 / +4 lines)
Lines 1-7 Link Here
1
Index: contrib/emacs/Makefile.in
1
--- contrib/emacs/Makefile.in.orig	2000-02-24 18:01:08 UTC
2
--- contrib/emacs/Makefile.in.orig	2011-09-27 15:17:26.000000000 +0900
2
+++ contrib/emacs/Makefile.in
3
+++ contrib/emacs/Makefile.in	2011-09-27 15:18:10.000000000 +0900
3
@@ -159,8 +159,9 @@ Makefile: $(srcdir)/Makefile.in  $(top_b
4
@@ -159,8 +159,9 @@
5
 
4
 
6
 install-dist_lispLISP: $(dist_lisp_LISP) $(ELCFILES)
5
 install-dist_lispLISP: $(dist_lisp_LISP) $(ELCFILES)
7
 	@$(NORMAL_INSTALL)
6
 	@$(NORMAL_INSTALL)
Lines 13-19 Link Here
13
 	  if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \
12
 	  if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \
14
 	  f="`echo $$p | sed -e 's|^.*/||'`"; \
13
 	  f="`echo $$p | sed -e 's|^.*/||'`"; \
15
 	  echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(lispdir)/$$f"; \
14
 	  echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(lispdir)/$$f"; \
16
@@ -169,7 +170,8 @@
15
@@ -169,7 +170,8 @@ install-dist_lispLISP: $(dist_lisp_LISP)
17
 	    echo " $(INSTALL_DATA) $${p}c $(DESTDIR)$(lispdir)/$${f}c"; \
16
 	    echo " $(INSTALL_DATA) $${p}c $(DESTDIR)$(lispdir)/$${f}c"; \
18
 	    $(INSTALL_DATA) $${p}c $(DESTDIR)$(lispdir)/$${f}c; \
17
 	    $(INSTALL_DATA) $${p}c $(DESTDIR)$(lispdir)/$${f}c; \
19
 	  else : ; fi; \
18
 	  else : ; fi; \
(-)files/patch-contrib-tmpdircreation (-116 lines)
Lines 1-116 Link Here
1
diff -ru contrib.orig/card.in contrib/card.in
2
--- contrib.orig/card.in	Thu Dec 30 19:23:25 2004
3
+++ contrib/card.in	Thu Dec 30 19:29:49 2004
4
@@ -38,7 +38,7 @@
5
 LC_ALL="${LC_ALL-C}" export LC_ALL
6
 print_form_feeds=:
7
 RM="/bin/rm -rf"
8
-tmp_dir=${TMPDIR-/tmp}/$program.$$
9
+tmp_dir=$(mktemp -d -t ${program}) || exit 1
10
 tmp_file=$tmp_dir/card
11
 success=false
12
 verbose=:
13
@@ -190,7 +190,6 @@
14
 
15
 # Create a tmp dir and be ready to clean up
16
 trap "$RM $tmp_dir" 0 1 2 15
17
-(umask 077 && mkdir $tmp_dir) || exit 1
18
 
19
 case $LC_ALL in
20
   fr) footer="Engendré par $version_short" ;;
21
diff -ru contrib.orig/fixps.in contrib/fixps.in
22
--- contrib.orig/fixps.in	Thu Dec 30 19:23:25 2004
23
+++ contrib/fixps.in	Thu Dec 30 19:31:22 2004
24
@@ -38,7 +38,7 @@
25
 run_gs=0
26
 # What action to perform: fixps, cat, check, and gs
27
 task=fixps
28
-tmpdir=/tmp/$program.$$
29
+tmpdir=$(mktemp -d -t ${program}) || exit 1
30
 verbose=echo
31
 
32
 # The version/usage strings
33
@@ -191,7 +191,6 @@
34
   trap "/bin/rm -rf $tmpdir" 0 1 2 3 13 15
35
 fi
36
 
37
-mkdir $tmpdir
38
 fixps_sed=$tmpdir/fixps.sed
39
 
40
 # If printing from stdin, save into a tmp file
41
diff -ru contrib.orig/pdiff.in contrib/pdiff.in
42
--- contrib.orig/pdiff.in	Thu Dec 30 19:23:25 2004
43
+++ contrib/pdiff.in	Thu Dec 30 19:16:59 2004
44
@@ -34,7 +34,7 @@
45
 diff_options='-u'
46
 file=
47
 output=
48
-tmpdir=/tmp/$program.$$
49
+tmpdir=$(mktemp -d -t ${program}) || exit 1
50
 verbose=echo
51
 wdiff_prog=${WDIFF:-wdiff}
52
 wdiff_options='-w[wd- -x-wd] -y{wd+ -z+wd}'
53
diff -ru contrib.orig/psmandup.in contrib/psmandup.in
54
--- contrib.orig/psmandup.in	Thu Dec 30 19:23:25 2004
55
+++ contrib/psmandup.in	Thu Dec 30 19:32:30 2004
56
@@ -36,7 +36,7 @@
57
 message=
58
 psselect=${PSSELECT:-psselect}
59
 psset=${PSSET:-psset}
60
-tmpdir=/tmp/$program.$$
61
+tmpdir=$(mktemp -d -t ${program}) || exit 1
62
 
63
 # These two must be kept in synch.  They are opposed.
64
 verbose=echo
65
@@ -184,8 +184,6 @@
66
   # Temp dir.  Get ready not to leave junk (if not debugging)
67
   trap "/bin/rm -rf $tmpdir" 0 1 2 3 13 15
68
 fi
69
-
70
-mkdir $tmpdir
71
 
72
 # If printing from stdin, save into a tmp file
73
 if test $file = '-'; then
74
diff -ru contrib.orig/psset.in contrib/psset.in
75
--- contrib.orig/psset.in	Thu Dec 30 19:23:25 2004
76
+++ contrib/psset.in	Thu Dec 30 19:33:50 2004
77
@@ -33,7 +33,7 @@
78
 output=-
79
 pagedevices=	# `;' separated list of `key:value'
80
 quiet=:         # i.e., verbose
81
-tmpdir=${TMPDIR:-/tmp}/$program.$$
82
+tmpdir=$(mktemp -d -t ${program}) || exit 1
83
 sedscript=$tmpdir/psset.sed
84
 
85
 # The version/usage strings
86
@@ -185,8 +185,6 @@
87
       echo "$help"  1>&2
88
       exit 1;;
89
 esac
90
-
91
-mkdir $tmpdir
92
 
93
 if test -n "$debug"; then
94
   # Set -x now if debugging
95
diff -ru contrib.orig/texi2dvi4a2ps contrib/texi2dvi4a2ps
96
--- contrib.orig/texi2dvi4a2ps	Thu Dec 30 19:23:25 2004
97
+++ contrib/texi2dvi4a2ps	Thu Dec 30 19:34:36 2004
98
@@ -91,7 +91,7 @@
99
 quiet=          # by default let the tools' message be displayed
100
 set_language=
101
 textra=
102
-tmpdir=${TMPDIR:-/tmp}/t2d$$  # avoid collisions on 8.3 filesystems.
103
+tmpdir=$(mktemp -d -t ${program}) || exit 1
104
 txincludes=     # TEXINPUTS extensions
105
 txiprereq=19990129 # minimum texinfo.tex version to have macro expansion
106
 verbose=false   # echo for verbose mode
107
@@ -202,9 +202,6 @@
108
 if test -z "$debug"; then
109
   trap "cd / && rm -rf $tmpdir" 0 1 2 15
110
 fi
111
-
112
-# Create the temporary directory with strict rights
113
-(umask 077 && mkdir $tmpdir) || exit 1
114
 
115
 # Prepare the tools we might need.  This may be extra work in some
116
 # cases, but improves the readibility of the script.
(-)files/patch-contrib_card.in (+19 lines)
Line 0 Link Here
1
--- contrib/card.in.orig	2000-01-27 00:42:36 UTC
2
+++ contrib/card.in
3
@@ -38,7 +38,7 @@ help="Try \`$program --help' for more in
4
 LC_ALL="${LC_ALL-C}" export LC_ALL
5
 print_form_feeds=:
6
 RM="/bin/rm -rf"
7
-tmp_dir=${TMPDIR-/tmp}/$program.$$
8
+tmp_dir=$(mktemp -d -t ${program}) || exit 1
9
 tmp_file=$tmp_dir/card
10
 success=false
11
 verbose=:
12
@@ -190,7 +190,6 @@ fi
13
 
14
 # Create a tmp dir and be ready to clean up
15
 trap "$RM $tmp_dir" 0 1 2 15
16
-(umask 077 && mkdir $tmp_dir) || exit 1
17
 
18
 case $LC_ALL in
19
   fr) footer="Engendré par $version_short" ;;
(-)files/patch-contrib_fixps.in (+19 lines)
Line 0 Link Here
1
--- contrib/fixps.in.orig	2000-02-21 08:16:15 UTC
2
+++ contrib/fixps.in
3
@@ -38,7 +38,7 @@ output=-	# Default is stdout
4
 run_gs=0
5
 # What action to perform: fixps, cat, check, and gs
6
 task=fixps
7
-tmpdir=/tmp/$program.$$
8
+tmpdir=$(mktemp -d -t ${program}) || exit 1
9
 verbose=echo
10
 
11
 # The version/usage strings
12
@@ -191,7 +191,6 @@ else
13
   trap "/bin/rm -rf $tmpdir" 0 1 2 3 13 15
14
 fi
15
 
16
-mkdir $tmpdir
17
 fixps_sed=$tmpdir/fixps.sed
18
 
19
 # If printing from stdin, save into a tmp file
(-)files/patch-contrib_pdiff.in (+11 lines)
Line 0 Link Here
1
--- contrib/pdiff.in.orig	1999-10-24 15:07:51 UTC
2
+++ contrib/pdiff.in
3
@@ -34,7 +34,7 @@ diff_prog=${DIFF:-diff}
4
 diff_options='-u'
5
 file=
6
 output=
7
-tmpdir=/tmp/$program.$$
8
+tmpdir=$(mktemp -d -t ${program}) || exit 1
9
 verbose=echo
10
 wdiff_prog=${WDIFF:-wdiff}
11
 wdiff_options='-w[wd- -x-wd] -y{wd+ -z+wd}'
(-)files/patch-contrib_psmandup.in (+20 lines)
Line 0 Link Here
1
--- contrib/psmandup.in.orig	1999-10-24 13:06:42 UTC
2
+++ contrib/psmandup.in
3
@@ -36,7 +36,7 @@ fixps=${FIXPS:-fixps}
4
 message=
5
 psselect=${PSSELECT:-psselect}
6
 psset=${PSSET:-psset}
7
-tmpdir=/tmp/$program.$$
8
+tmpdir=$(mktemp -d -t ${program}) || exit 1
9
 
10
 # These two must be kept in synch.  They are opposed.
11
 verbose=echo
12
@@ -185,8 +185,6 @@ else
13
   trap "/bin/rm -rf $tmpdir" 0 1 2 3 13 15
14
 fi
15
 
16
-mkdir $tmpdir
17
-
18
 # If printing from stdin, save into a tmp file
19
 if test $file = '-'; then
20
   file=$tmpdir/stdin.ps
(-)files/patch-contrib_psset.in (+20 lines)
Line 0 Link Here
1
--- contrib/psset.in.orig	1999-10-24 12:41:46 UTC
2
+++ contrib/psset.in
3
@@ -33,7 +33,7 @@ fixps=${FIXPS:-fixps}
4
 output=-
5
 pagedevices=	# `;' separated list of `key:value'
6
 quiet=:         # i.e., verbose
7
-tmpdir=${TMPDIR:-/tmp}/$program.$$
8
+tmpdir=$(mktemp -d -t ${program}) || exit 1
9
 sedscript=$tmpdir/psset.sed
10
 
11
 # The version/usage strings
12
@@ -186,8 +186,6 @@ case $# in
13
       exit 1;;
14
 esac
15
 
16
-mkdir $tmpdir
17
-
18
 if test -n "$debug"; then
19
   # Set -x now if debugging
20
   set -x
(-)files/patch-contrib_texi2dvi4a2ps (+21 lines)
Line 0 Link Here
1
--- contrib/texi2dvi4a2ps.orig	2000-02-24 17:45:31 UTC
2
+++ contrib/texi2dvi4a2ps
3
@@ -91,7 +91,7 @@ oname=		# --output
4
 quiet=          # by default let the tools' message be displayed
5
 set_language=
6
 textra=
7
-tmpdir=${TMPDIR:-/tmp}/t2d$$  # avoid collisions on 8.3 filesystems.
8
+tmpdir=$(mktemp -d -t ${program}) || exit 1
9
 txincludes=     # TEXINPUTS extensions
10
 txiprereq=19990129 # minimum texinfo.tex version to have macro expansion
11
 verbose=false   # echo for verbose mode
12
@@ -203,9 +203,6 @@ if test -z "$debug"; then
13
   trap "cd / && rm -rf $tmpdir" 0 1 2 15
14
 fi
15
 
16
-# Create the temporary directory with strict rights
17
-(umask 077 && mkdir $tmpdir) || exit 1
18
-
19
 # Prepare the tools we might need.  This may be extra work in some
20
 # cases, but improves the readibility of the script.
21
 utildir=$tmpdir/utils
(-)files/patch-etc-Makefile.in (-3 / +3 lines)
Lines 1-6 Link Here
1
--- etc/Makefile.in.orig	Tue Nov 20 19:09:45 2001
1
--- etc/Makefile.in.orig	2000-02-24 17:55:34 UTC
2
+++ etc/Makefile.in	Tue Nov 20 19:09:53 2001
2
+++ etc/Makefile.in
3
@@ -131,7 +131,7 @@
3
@@ -131,7 +131,7 @@ l = @l@
4
 lispdir = @lispdir@
4
 lispdir = @lispdir@
5
 
5
 
6
 
6
 
(-)files/patch-intl_localealias.c (+20 lines)
Line 0 Link Here
1
--- intl/localealias.c.orig	1999-08-31 17:29:35 UTC
2
+++ intl/localealias.c
3
@@ -329,6 +329,17 @@ read_alias_file (fname, fname_len)
4
 		      FREE_BLOCKS (block_list);
5
 		      return added;
6
 		    }
7
+		  if (string_space != new_pool)
8
+		    {
9
+		      size_t i;
10
+
11
+		      for (i = 0; i < nmap; i++)
12
+			{
13
+			  map[i].alias += new_pool - string_space;
14
+			  map[i].value += new_pool - string_space;
15
+			}
16
+		    }
17
+
18
 		  string_space = new_pool;
19
 		  string_space_max = new_size;
20
 		}
(-)files/patch-lib_options.c (+18 lines)
Line 0 Link Here
1
--- lib/options.c.orig	1999-08-31 17:42:41 UTC
2
+++ lib/options.c
3
@@ -493,6 +493,15 @@ a2ps_handle_options (a2ps_job * job, int
4
 	  /* A font size is given */
5
 	  job->fontsize = get_length ("--font-size", cp,
6
 				      0.0, 0.0, "pt", range_min_strict);
7
+	  if (job->fontsize == 0.0) 
8
+	  {
9
+	    error (0, 0, _("invalid argument %s for -f or --font-size option"),
10
+	      cp);
11
+	    fprintf (stderr,
12
+	      _("Valid arguments are floats with optonal units!\n"));
13
+	    fprintf (stderr, _("Try `a2ps --help' for more information.\n"));
14
+	    exit (EXIT_FAILURE);
15
+	  }
16
 	  job->columns_requested = 0;
17
 	  job->lines_requested = 0;
18
 	}
(-)files/patch-lib_printers.c (+13 lines)
Line 0 Link Here
1
--- lib/printers.c.orig	1999-10-11 22:01:59 UTC
2
+++ lib/printers.c
3
@@ -315,8 +315,8 @@ a2ps_printers_new (struct a2ps_common_s 
4
   res->ppd = NULL;		/* Printer's ppd are not read yet */
5
 
6
   /* Output */
7
-  /* Default is to send to default printer */
8
-  res->flag_output_is_printer = true;
9
+  /* Default is to send to stdout */
10
+  res->flag_output_is_printer = false;
11
   res->flag_output_name = NULL;
12
   res->output_is_file = true;
13
   res->output_name = NULL;
(-)files/patch-lib_printlen.c (+27 lines)
Line 0 Link Here
1
--- lib/printlen.c.orig	1999-08-31 17:42:42 UTC
2
+++ lib/printlen.c
3
@@ -28,14 +28,11 @@ Foundation, Inc., 59 Temple Place - Suit
4
 unsigned long strtoul ();
5
 
6
 static int
7
-int_printflen (const char *format, va_list *args)
8
+int_printflen (const char *format, va_list ap)
9
 {
10
   const char *cp;
11
   int total_width = 0;
12
   int width = 0;
13
-  va_list ap;
14
-
15
-  memcpy (&ap, args, sizeof (va_list));
16
 
17
   for (cp = format ; *cp ; cp++)
18
     {
19
@@ -99,7 +96,7 @@ int_printflen (const char *format, va_li
20
 int
21
 vprintflen (const char *format,  va_list args)
22
 {
23
-  return int_printflen (format, &args);
24
+  return int_printflen (format, args);
25
 }
26
 
27
 int
(-)files/patch-lib_title.c (+11 lines)
Line 0 Link Here
1
--- lib/title.c.orig	2015-09-25 08:26:23 UTC
2
+++ lib/title.c
3
@@ -88,6 +88,8 @@ title (stream, c, center_p, format, va_a
4
   if (center_p)
5
     for (padding = 0 ; padding < 79 - len ; padding += 2)
6
       putc (' ', stream);
7
+  va_end(args);
8
+  VA_START(args, format);
9
 # if HAVE_VPRINTF || _LIBC
10
   vfprintf (stream, format, args);
11
 # else
(-)files/patch-lib_xgethostname.c (+28 lines)
Line 0 Link Here
1
--- lib/xgethostname.c.orig	1999-08-28 17:11:35 UTC
2
+++ lib/xgethostname.c
3
@@ -21,6 +21,7 @@
4
 # include <config.h>
5
 #endif
6
 
7
+#include <sys/param.h>
8
 #include <sys/types.h>
9
 
10
 #include <errno.h>
11
@@ -38,7 +39,7 @@ extern int errno;
12
 int gethostname ();
13
 
14
 #ifndef INITIAL_HOSTNAME_LENGTH
15
-# define INITIAL_HOSTNAME_LENGTH 34
16
+# define INITIAL_HOSTNAME_LENGTH MAXHOSTNAMELEN
17
 #endif
18
 
19
 char *
20
@@ -63,7 +64,7 @@ xgethostname ()
21
       if (err == 0 && hostname[k] == '\0')
22
 	break;
23
 #ifdef ENAMETOOLONG
24
-      else if (err != 0 && errno != ENAMETOOLONG && errno != 0)
25
+      else if (err != 0 && errno != ENAMETOOLONG && errno != ENOMEM && errno != 0)
26
 	error (EXIT_FAILURE, errno, "gethostname");
27
 #endif
28
       size *= 2;
(-)files/patch-localealias.c (-20 lines)
Lines 1-20 Link Here
1
--- intl/localealias.c.orig	Tue Aug 31 13:29:35 1999
2
+++ intl/localealias.c	Tue Aug 12 11:09:53 2003
3
@@ -329,6 +329,17 @@
4
 		      FREE_BLOCKS (block_list);
5
 		      return added;
6
 		    }
7
+		  if (string_space != new_pool)
8
+		    {
9
+		      size_t i;
10
+
11
+		      for (i = 0; i < nmap; i++)
12
+			{
13
+			  map[i].alias += new_pool - string_space;
14
+			  map[i].value += new_pool - string_space;
15
+			}
16
+		    }
17
+
18
 		  string_space = new_pool;
19
 		  string_space_max = new_size;
20
 		}
(-)files/patch-ogonkify-Makefile.in (-3 / +3 lines)
Lines 1-6 Link Here
1
--- ogonkify/Makefile.in.orig	Tue Apr 20 00:07:03 1999
1
--- ogonkify/Makefile.in.orig	2000-01-07 13:00:49 UTC
2
+++ ogonkify/Makefile.in	Tue Apr 20 00:07:07 1999
2
+++ ogonkify/Makefile.in
3
@@ -37,7 +37,7 @@
3
@@ -33,7 +33,7 @@ oldincludedir = /usr/include
4
 
4
 
5
 DESTDIR =
5
 DESTDIR =
6
 
6
 
(-)files/patch-options.c (-18 lines)
Lines 1-18 Link Here
1
--- lib/options.c.orig	Thu Sep 21 23:22:36 2000
2
+++ lib/options.c	Thu Sep 21 23:22:42 2000
3
@@ -493,6 +493,15 @@
4
 	  /* A font size is given */
5
 	  job->fontsize = get_length ("--font-size", cp,
6
 				      0.0, 0.0, "pt", range_min_strict);
7
+	  if (job->fontsize == 0.0) 
8
+	  {
9
+	    error (0, 0, _("invalid argument %s for -f or --font-size option"),
10
+	      cp);
11
+	    fprintf (stderr,
12
+	      _("Valid arguments are floats with optonal units!\n"));
13
+	    fprintf (stderr, _("Try `a2ps --help' for more information.\n"));
14
+	    exit (EXIT_FAILURE);
15
+	  }
16
 	  job->columns_requested = 0;
17
 	  job->lines_requested = 0;
18
 	}
(-)files/patch-printers.c (-13 lines)
Lines 1-13 Link Here
1
--- lib/printers.c.orig	Tue Oct 12 00:01:59 1999
2
+++ lib/printers.c	Wed May  2 11:23:25 2001
3
@@ -315,8 +315,8 @@
4
   res->ppd = NULL;		/* Printer's ppd are not read yet */
5
 
6
   /* Output */
7
-  /* Default is to send to default printer */
8
-  res->flag_output_is_printer = true;
9
+  /* Default is to send to stdout */
10
+  res->flag_output_is_printer = false;
11
   res->flag_output_name = NULL;
12
   res->output_is_file = true;
13
   res->output_name = NULL;
(-)files/patch-select.c (-57 lines)
Lines 1-57 Link Here
1
--- src/select.c.orig	Thu Dec 16 02:04:56 1999
2
+++ src/select.c	Sat Aug 21 12:05:31 2004
3
@@ -131,6 +131,36 @@
4
   return 1;
5
 }
6
 
7
+/* escapes the name of a file so that the shell groks it in 'single' q.marks. 
8
+   The resulting pointer has to be free()ed when not longer used. */
9
+char *
10
+shell_escape(const char *fn)
11
+{
12
+  size_t len = 0;
13
+  const char *inp;
14
+  char *retval, *outp;
15
+
16
+  for(inp = fn; *inp; ++inp)
17
+    switch(*inp)
18
+    {
19
+      case '\'': len += 4; break;
20
+      default:   len += 1; break;
21
+    }
22
+
23
+  outp = retval = malloc(len + 1);
24
+  if(!outp)
25
+    return NULL; /* perhaps one should do better error handling here */
26
+  for(inp = fn; *inp; ++inp)
27
+    switch(*inp)
28
+    {
29
+      case '\'': *outp++ = '\''; *outp++ = '\\'; *outp++ = '\'', *outp++ = '\''; break;
30
+      default:   *outp++ = *inp; break;
31
+    }
32
+  *outp = 0;
33
+
34
+  return retval;
35
+}
36
+
37
 /* What says file about the type of a file (result is malloc'd).  NULL
38
   if could not be run.  */
39
 
40
@@ -144,11 +174,15 @@
41
   if (IS_EMPTY (job->file_command))
42
     return NULL;
43
 
44
+  filename = shell_escape(filename);
45
+  if(filename == NULL)
46
+    return NULL;
47
   /* Call file(1) with the correct option */
48
-  command = ALLOCA (char, (2
49
+  command = ALLOCA (char, (4
50
 			   + strlen (job->file_command)
51
 			   + ustrlen (filename)));
52
-  sprintf (command, "%s %s", job->file_command, (const char *) filename);
53
+  sprintf (command, "%s '%s'", job->file_command, (const char *) filename);
54
+  free(filename);
55
   message (msg_tool, (stderr, "Reading pipe: `%s'\n", command));
56
   file_out = popen (command, "r");
57
 
(-)files/patch-src_select.c (+57 lines)
Line 0 Link Here
1
--- src/select.c.orig	1999-12-16 01:04:56 UTC
2
+++ src/select.c
3
@@ -131,6 +131,36 @@ sheets_map_load_main (void)
4
   return 1;
5
 }
6
 
7
+/* escapes the name of a file so that the shell groks it in 'single' q.marks. 
8
+   The resulting pointer has to be free()ed when not longer used. */
9
+char *
10
+shell_escape(const char *fn)
11
+{
12
+  size_t len = 0;
13
+  const char *inp;
14
+  char *retval, *outp;
15
+
16
+  for(inp = fn; *inp; ++inp)
17
+    switch(*inp)
18
+    {
19
+      case '\'': len += 4; break;
20
+      default:   len += 1; break;
21
+    }
22
+
23
+  outp = retval = malloc(len + 1);
24
+  if(!outp)
25
+    return NULL; /* perhaps one should do better error handling here */
26
+  for(inp = fn; *inp; ++inp)
27
+    switch(*inp)
28
+    {
29
+      case '\'': *outp++ = '\''; *outp++ = '\\'; *outp++ = '\'', *outp++ = '\''; break;
30
+      default:   *outp++ = *inp; break;
31
+    }
32
+  *outp = 0;
33
+
34
+  return retval;
35
+}
36
+
37
 /* What says file about the type of a file (result is malloc'd).  NULL
38
   if could not be run.  */
39
 
40
@@ -144,11 +174,15 @@ file_verdict_on (const uchar *filename)
41
   if (IS_EMPTY (job->file_command))
42
     return NULL;
43
 
44
+  filename = shell_escape(filename);
45
+  if(filename == NULL)
46
+    return NULL;
47
   /* Call file(1) with the correct option */
48
-  command = ALLOCA (char, (2
49
+  command = ALLOCA (char, (4
50
 			   + strlen (job->file_command)
51
 			   + ustrlen (filename)));
52
-  sprintf (command, "%s %s", job->file_command, (const char *) filename);
53
+  sprintf (command, "%s '%s'", job->file_command, (const char *) filename);
54
+  free(filename);
55
   message (msg_tool, (stderr, "Reading pipe: `%s'\n", command));
56
   file_out = popen (command, "r");
57
 
(-)files/patch-xgethostname.c (-28 lines)
Lines 1-28 Link Here
1
--- lib/xgethostname.c.orig	Tue Sep  4 00:51:26 2001
2
+++ lib/xgethostname.c	Tue Sep  4 00:55:39 2001
3
@@ -21,6 +21,7 @@
4
 # include <config.h>
5
 #endif
6
 
7
+#include <sys/param.h>
8
 #include <sys/types.h>
9
 
10
 #include <errno.h>
11
@@ -38,7 +39,7 @@
12
 int gethostname ();
13
 
14
 #ifndef INITIAL_HOSTNAME_LENGTH
15
-# define INITIAL_HOSTNAME_LENGTH 34
16
+# define INITIAL_HOSTNAME_LENGTH MAXHOSTNAMELEN
17
 #endif
18
 
19
 char *
20
@@ -63,7 +64,7 @@
21
       if (err == 0 && hostname[k] == '\0')
22
 	break;
23
 #ifdef ENAMETOOLONG
24
-      else if (err != 0 && errno != ENAMETOOLONG && errno != 0)
25
+      else if (err != 0 && errno != ENAMETOOLONG && errno != ENOMEM && errno != 0)
26
 	error (EXIT_FAILURE, errno, "gethostname");
27
 #endif
28
       size *= 2;

Return to bug 203326