diff options
author | Karl Berry <karl@freefriends.org> | 2010-02-18 18:03:18 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2010-02-18 18:03:18 +0000 |
commit | e826cf1e931e56a27391f357253038be01f25396 (patch) | |
tree | 2f3195394c18fc3fde2b8ef8ef4de296e96d4a08 /Build/source/texk/dvipsk | |
parent | 265ec325225e513352908a8d61e2d0bc06d6ca09 (diff) |
move common-test.pl to common directory; new popen/gzip test for dvipsk
git-svn-id: svn://tug.org/texlive/trunk@17085 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvipsk')
-rw-r--r-- | Build/source/texk/dvipsk/ChangeLog | 11 | ||||
-rw-r--r-- | Build/source/texk/dvipsk/Makefile.am | 5 | ||||
-rw-r--r-- | Build/source/texk/dvipsk/Makefile.in | 2 | ||||
-rwxr-xr-x | Build/source/texk/dvipsk/quotecmd-test.pl | 31 | ||||
-rw-r--r-- | Build/source/texk/dvipsk/search.c | 31 | ||||
-rw-r--r-- | Build/source/texk/dvipsk/testdata/quotecmd.tex | 16 |
6 files changed, 80 insertions, 16 deletions
diff --git a/Build/source/texk/dvipsk/ChangeLog b/Build/source/texk/dvipsk/ChangeLog index 5d53f732b94..abe63992c15 100644 --- a/Build/source/texk/dvipsk/ChangeLog +++ b/Build/source/texk/dvipsk/ChangeLog @@ -1,3 +1,14 @@ +2010-02-18 Karl Berry <karl@tug.org> + + * Makefile.am (TESTS): add quotecmd-test.pl. + * quotecmd-test.pl, + * testdata/quotecmd.tex: new files. + * search.c (search): selfautoloc gunzip, and quote name before + calling popen. + (kpse_quote_name, kpse_self_autoloc_prog): new fns, + only temporarily here until we factor out the common code from + texmfmp.c. + 2010-02-12 Peter Breitenlohner <peb@mppmu.mpg.de> * dvips.c (main): Add '#if defined(KPSE_DEBUG)' to allow diff --git a/Build/source/texk/dvipsk/Makefile.am b/Build/source/texk/dvipsk/Makefile.am index 5eb0b649c5e..b55888430fe 100644 --- a/Build/source/texk/dvipsk/Makefile.am +++ b/Build/source/texk/dvipsk/Makefile.am @@ -109,9 +109,8 @@ EXTRA_DIST = $(dist_prologues) texc.script CLEANFILES = $(prologues) texc.lpro -## dvips test -## -TESTS = beginfontk1.test dvips.test pfbincl.test +## dvips tests +TESTS = beginfontk1.test dvips.test pfbincl.test quotecmd-test.pl TESTS_ENVIRONMENT = TEXMFCNF=$(srcdir)/../kpathsea TEXCONFIG=$(srcdir)/testdata TESTS_ENVIRONMENT += TEXFONTS=$(srcdir)/testdata diff --git a/Build/source/texk/dvipsk/Makefile.in b/Build/source/texk/dvipsk/Makefile.in index e13d2a83429..9237a92bf57 100644 --- a/Build/source/texk/dvipsk/Makefile.in +++ b/Build/source/texk/dvipsk/Makefile.in @@ -401,7 +401,7 @@ EXTRA_DIST = $(dist_prologues) texc.script beginfontk1.test dvips.test \ mvs psfonts.map tex vmcms vms CLEANFILES = $(prologues) texc.lpro dvipstst.ps missfont.log mtest.ps \ pfbincl.ps -TESTS = beginfontk1.test dvips.test pfbincl.test +TESTS = beginfontk1.test dvips.test pfbincl.test quotecmd-test.pl TESTS_ENVIRONMENT = TEXMFCNF=$(srcdir)/../kpathsea \ TEXCONFIG=$(srcdir)/testdata TEXFONTS=$(srcdir)/testdata \ TEXPSHEADERS=$(srcdir)/testdata diff --git a/Build/source/texk/dvipsk/quotecmd-test.pl b/Build/source/texk/dvipsk/quotecmd-test.pl new file mode 100755 index 00000000000..2d1f90da004 --- /dev/null +++ b/Build/source/texk/dvipsk/quotecmd-test.pl @@ -0,0 +1,31 @@ +#!/usr/bin/env perl +# $Id: bibtex-openout-test.pl 16507 2009-12-25 01:19:05Z karl $ +# Public domain. Originally written 2010, Karl Berry. +# Check that dvips quotes external command arguments. + +BEGIN { chomp ($srcdir = $ENV{"srcdir"} || `dirname $0`); } +require "$srcdir/../tests/common-test.pl"; + +exit (&main ()); + +sub main +{ + # create the weirdly-named file which dvips executes with popen. + # quotecmd.tex itself also creates it, but we don't want to run TeX in + # this test, nor do we want such a weirdly-named file in our + # repository, so create it here. Leave it in place, so we can run the + # program under the debugging if we need to. + my $weirdf = ' 2>&1 | echo badnews >pwned.txt #.gz'; + unlink ($weirdf); # ensure no leftover + open (WEIRDF, ">", $weirdf); + close (WEIRDF) || die "open(weird file name) failed: $!"; + + $badfile = "pwned.txt"; # will be created if program is broken + unlink ($badfile); # ensure no leftover from previous test + + my @args = ("$srcdir/testdata/quotecmd.dvi", qw(-o /dev/null)); + my $ret = &test_run ("./dvips", @args); + + my $bad = -f $badfile; # file should not have been created + return $bad; +} diff --git a/Build/source/texk/dvipsk/search.c b/Build/source/texk/dvipsk/search.c index da760c66d31..083e8ddd4ba 100644 --- a/Build/source/texk/dvipsk/search.c +++ b/Build/source/texk/dvipsk/search.c @@ -7,6 +7,10 @@ */ #include "dvips.h" /* The copyright notice in that file is included too! */ +#ifndef KPATHSEA +"goodbye, search.c can only be compiled with -DKPATHSEA" +#endif + #include "protos_add.h" /* external declarations */ #include <kpathsea/c-ctype.h> @@ -22,9 +26,9 @@ int to_close ; /* use fclose or pclose? */ char *realnameoffile ; -/* Return safely quoted version of NAME. That means as "..." on Windows - and '...' on Unix, with any occurrences of the quote char quoted with - a \. Result is always in new memory, and NAME is unchanged. */ +/* Return safely quoted version of NAME. That means using "..." on + Windows and '...' on Unix, with any occurrences of the quote char + quoted with a \. Result is always in new memory; NAME is unchanged. */ #ifdef WIN32 #define QUOTE '"' @@ -48,7 +52,7 @@ kpse_quote_name (const char *name) *q++ = QUOTE; *q = 0; - return q; + return quoted; } @@ -56,9 +60,9 @@ kpse_quote_name (const char *name) changed to \. On Unix, return a copy of PROG. Result is always in new memory. No safeness or other quoting is done on PROG. - This is necessary because Windows always wants to run programs out of - the current directory. So for security, we want to ensure that we - are invoking programs from our own binary directory, not via PATH. */ + This is necessary because Windows likes to run programs out of the + current directory. So for security, we want to ensure that we are + invoking programs from our own binary directory, not via PATH. */ static char * kpse_selfautoloc_prog (const char *prog) @@ -75,6 +79,7 @@ kpse_selfautoloc_prog (const char *prog) /* Prepend that to PROG. */ ret = concat3 (selfautoloc, "\\", prog); + free (selfautoloc); #else /* not WIN32 */ ret = xstrdup (prog); @@ -97,7 +102,8 @@ search(kpse_file_format_type format, const char *file, const char *mode) if (secure == 2) { #endif /* an absolute path is denied */ - if (kpse_absolute_p (file, false)) return NULL; + if (kpse_absolute_p (file, false)) + return NULL; if (file[0] == '.' && file[1] == '.' && IS_DIR_SEP(file[2])) { /* a relative path starting with ../ is denied */ @@ -129,14 +135,14 @@ search(kpse_file_format_type format, const char *file, const char *mode) && ((len > 2 && FILESTRCASEEQ (found_name + len - 2, ".Z")) || (len > 3 && FILESTRCASEEQ (found_name + len - 3, ".gz")))) { /* automatically but safely decompress. */ -/* char *quoted_name = kpse_quote_name (found_name); */ + char *quoted_name = kpse_quote_name (found_name); char *cmd; char *prog = kpse_selfautoloc_prog (GUNZIP); - cmd = concat3 (prog, " -c ", found_name); + cmd = concat3 (prog, " -c ", quoted_name); ret = popen (cmd, "r"); to_close = USE_PCLOSE; free (cmd); -/* free (quoted_name); */ + free (quoted_name); free (prog); } else { ret = fopen (found_name, mode); @@ -161,7 +167,8 @@ search(kpse_file_format_type format, const char *file, const char *mode) FILE * -pksearch(const char *file, const char *mode, halfword dpi, char **name_ret, int *dpi_ret) +pksearch(const char *file, const char *mode, halfword dpi, + char **name_ret, int *dpi_ret) { FILE *ret; kpse_glyph_file_type font_file; diff --git a/Build/source/texk/dvipsk/testdata/quotecmd.tex b/Build/source/texk/dvipsk/testdata/quotecmd.tex new file mode 100644 index 00000000000..a294e703aa1 --- /dev/null +++ b/Build/source/texk/dvipsk/testdata/quotecmd.tex @@ -0,0 +1,16 @@ +% $Id: write18-quote.tex 16695 2010-01-13 01:18:02Z karl $ +% Public domain. Originally written 2009, Alexander Cherepanov. + +\catcode`\# = 12 +\def\cmd{" 2>&1 | echo badnews > pwned.txt #.gz"} + +% create this weirdly-named file. +\catcode0 = 12 +\immediate\openout1 \cmd^^@ +\immediate\closeout1 + +% write out a special referring to it. +% if it exists when dvips is run, it will be executed with popen. +\special{psfile=\cmd} +\nopagenumbers +\end |