Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 77408 | Differences between
and this patch

Collapse All | Expand All

(-)orig/enscript-1.6.3/src/gsint.h (+5 lines)
Lines 701-704 FILE *printer_open ___P ((char *cmd, cha Link Here
701
 */
701
 */
702
void printer_close ___P ((void *context));
702
void printer_close ___P ((void *context));
703
703
704
/*
705
 * Escape filenames for shell usage
706
 */
707
char *shell_escape ___P ((const char *fn));
708
704
#endif /* not GSINT_H */
709
#endif /* not GSINT_H */
(-)orig/enscript-1.6.3/src/main.c (-6 / +16 lines)
Lines 1555-1563 name width\theight\tllx\tlly Link Here
1555
      buffer_append (&cmd, intbuf);
1555
      buffer_append (&cmd, intbuf);
1556
      buffer_append (&cmd, " ");
1556
      buffer_append (&cmd, " ");
1557
1557
1558
      buffer_append (&cmd, "-Ddocument_title=\"");
1558
      buffer_append (&cmd, "-Ddocument_title=\'");
1559
      buffer_append (&cmd, title);
1559
      if ((cp = shell_escape (title)) != NULL)
1560
      buffer_append (&cmd, "\" ");
1560
	{
1561
	  buffer_append (&cmd, cp);
1562
	  free (cp);
1563
	}
1564
      buffer_append (&cmd, "\' ");
1561
1565
1562
      buffer_append (&cmd, "-Dtoc=");
1566
      buffer_append (&cmd, "-Dtoc=");
1563
      buffer_append (&cmd, toc ? "1" : "0");
1567
      buffer_append (&cmd, toc ? "1" : "0");
Lines 1574-1581 name width\theight\tllx\tlly Link Here
1574
      /* Append input files. */
1578
      /* Append input files. */
1575
      for (i = optind; i < argc; i++)
1579
      for (i = optind; i < argc; i++)
1576
	{
1580
	{
1577
	  buffer_append (&cmd, " ");
1581
	  char *cp;
1578
	  buffer_append (&cmd, argv[i]);
1582
	  if ((cp = shell_escape (argv[i])) != NULL)
1583
	    {
1584
	      buffer_append (&cmd, " \'");
1585
	      buffer_append (&cmd, cp);
1586
	      buffer_append (&cmd, "\'");
1587
	      free (cp);
1588
	    }
1579
	}
1589
	}
1580
1590
1581
      /* And do the job. */
1591
      /* And do the job. */
Lines 1636-1642 name width\theight\tllx\tlly Link Here
1636
				 buffer_ptr (opts), buffer_len (opts));
1645
				 buffer_ptr (opts), buffer_len (opts));
1637
	    }
1646
	    }
1638
1647
1639
	  buffer_append (&buffer, " \"%s\"");
1648
	  buffer_append (&buffer, " \'%s\'");
1640
1649
1641
	  input_filter = buffer_copy (&buffer);
1650
	  input_filter = buffer_copy (&buffer);
1642
	  input_filter_stdin = "-";
1651
	  input_filter_stdin = "-";
(-)orig/enscript-1.6.3/src/util.c (-5 / +45 lines)
Lines 1239-1244 escape_string (char *string) Link Here
1239
1239
1240
  /* Create result. */
1240
  /* Create result. */
1241
  cp = xmalloc (len + 1);
1241
  cp = xmalloc (len + 1);
1242
  if (cp == NULL)
1243
      return NULL;
1242
  for (i = 0, j = 0; string[i]; i++)
1244
  for (i = 0, j = 0; string[i]; i++)
1243
    switch (string[i])
1245
    switch (string[i])
1244
      {
1246
      {
Lines 1879-1884 is_open (InputStream *is, FILE *fp, char Link Here
1879
      char *cmd = NULL;
1881
      char *cmd = NULL;
1880
      int cmdlen;
1882
      int cmdlen;
1881
      int i, pos;
1883
      int i, pos;
1884
      char *cp;
1882
1885
1883
      is->is_pipe = 1;
1886
      is->is_pipe = 1;
1884
1887
Lines 1902-1913 is_open (InputStream *is, FILE *fp, char Link Here
1902
		{
1905
		{
1903
		case 's':
1906
		case 's':
1904
		  /* Expand cmd-buffer. */
1907
		  /* Expand cmd-buffer. */
1905
		  cmdlen += strlen (fname);
1908
		  if ((cp = shell_escape (fname)) != NULL)
1906
		  cmd = xrealloc (cmd, cmdlen);
1909
		    {
1910
		      cmdlen += strlen (cp);
1911
		      cmd = xrealloc (cmd, cmdlen);
1907
1912
1908
		  /* Paste filename. */
1913
		      /* Paste filename. */
1909
		  strcpy (cmd + pos, fname);
1914
		      strcpy (cmd + pos, cp);
1910
		  pos += strlen (fname);
1915
		      pos += strlen (cp);
1916
		      free (cp);
1917
		    }
1911
1918
1912
		  i++;
1919
		  i++;
1913
		  break;
1920
		  break;
Lines 2116-2118 buffer_len (Buffer *buffer) Link Here
2116
{
2123
{
2117
  return buffer->len;
2124
  return buffer->len;
2118
}
2125
}
2126
2127
/*
2128
 * Escapes the name of a file so that the shell groks it in 'single'
2129
 * quotation marks.  The resulting pointer has to be free()ed when not
2130
 * longer used.
2131
*/
2132
char *
2133
shell_escape(const char *fn)
2134
{
2135
  size_t len = 0;
2136
  const char *inp;
2137
  char *retval, *outp;
2138
2139
  for(inp = fn; *inp; ++inp)
2140
    switch(*inp)
2141
    {
2142
      case '\'': len += 4; break;
2143
      default:   len += 1; break;
2144
    }
2145
2146
  outp = retval = malloc(len + 1);
2147
  if(!outp)
2148
    return NULL; /* perhaps one should do better error handling here */
2149
  for(inp = fn; *inp; ++inp)
2150
    switch(*inp)
2151
    {
2152
      case '\'': *outp++ = '\''; *outp++ = '\\'; *outp++ = '\'', *outp++ = '\''; break;
2153
      default:   *outp++ = *inp; break;
2154
    }
2155
  *outp = 0;
2156
2157
  return retval;
2158
}
(-)enscript-1.6.3.CAN-2004-1184/src/psgen.c (-1 / +3 lines)
Lines 2385-2393 recognize_eps_file (Token *token) Link Here
2385
  MESSAGE (2, (stderr, "^@epsf=\"%s\"\n", token->u.epsf.filename));
2385
  MESSAGE (2, (stderr, "^@epsf=\"%s\"\n", token->u.epsf.filename));
2386
2386
2387
  i = strlen (token->u.epsf.filename);
2387
  i = strlen (token->u.epsf.filename);
2388
  /*
2388
  if (i > 0 && token->u.epsf.filename[i - 1] == '|')
2389
  if (i > 0 && token->u.epsf.filename[i - 1] == '|')
2389
    {
2390
    {
2390
      /* Read EPS data from pipe. */
2391
      / * Read EPS data from pipe. * /
2391
      token->u.epsf.pipe = 1;
2392
      token->u.epsf.pipe = 1;
2392
      token->u.epsf.filename[i - 1] = '\0';
2393
      token->u.epsf.filename[i - 1] = '\0';
2393
      token->u.epsf.fp = popen (token->u.epsf.filename, "r");
2394
      token->u.epsf.fp = popen (token->u.epsf.filename, "r");
Lines 2400-2405 recognize_eps_file (Token *token) Link Here
2400
	}
2401
	}
2401
    }
2402
    }
2402
  else
2403
  else
2404
  */
2403
    {
2405
    {
2404
      char *filename;
2406
      char *filename;
2405
2407
(-)enscript-1.6.3.CAN-2004-1185/src/psgen.c (-2 / +3 lines)
Lines 2034-2041 dump_ps_page_header (char *fname, int em Link Here
2034
  else
2034
  else
2035
    {
2035
    {
2036
      ftail++;
2036
      ftail++;
2037
      strncpy (buf, fname, ftail - fname);
2037
      i = ftail - fname >= sizeof (buf)-1 ? sizeof (buf)-1 : ftail - fname;
2038
      buf[ftail - fname] = '\0';
2038
      strncpy (buf, fname, i);
2039
      buf[i] = '\0';
2039
    }
2040
    }
2040
2041
2041
  if (nup > 1)
2042
  if (nup > 1)
(-)enscript-1.6.3.CAN-2004-1185/src/util.c (-1 / +2 lines)
Lines 2003-2009 is_getc (InputStream *is) Link Here
2003
	return EOF;
2003
	return EOF;
2004
2004
2005
      /* Read more data. */
2005
      /* Read more data. */
2006
      is->data_in_buf = fread (is->buf, 1, sizeof (is->buf), is->fp);
2006
      memset (is->buf, 0, sizeof (is->buf));
2007
      is->data_in_buf = fread (is->buf, 1, sizeof (is->buf)-1, is->fp);
2007
      is->bufpos = 0;
2008
      is->bufpos = 0;
2008
      is->nreads++;
2009
      is->nreads++;
2009
2010

Return to bug 77408