openbsd-ports/print/gv/patches/patch-source_file_c
brad 36a9392a98 Fix security issue with gv.
When GV detects that the document is either a PDF file or a
GZip compressed file, it executes some commands with the help of the
system() function. Unfortunately, these commands contain the
filename, which can be considered as untrusted user input. It is then
possible to distribute a file (with a meticulously chosen filename,
that even seems innocent) that causes execution of arbitrary
shell commands when it is read with GV.

http://www.epita.fr/~bevand_m/asa/asa-0000
2002-10-04 18:29:14 +00:00

27 lines
806 B
Plaintext

$OpenBSD: patch-source_file_c,v 1.1 2002/10/04 18:29:14 brad Exp $
--- source/file.c.orig Fri Jun 6 18:00:00 1997
+++ source/file.c Fri Oct 4 14:20:31 2002
@@ -285,6 +285,22 @@ file_fileIsNotUseful(fn)
}
/*############################################################*/
+/* file_nameIsDangerous */
+/*############################################################*/
+
+char *file_charsAllowedInName = "+,-./:=@\\^_";
+
+int
+file_nameIsDangerous(fn)
+ char *fn;
+{
+ for (; *fn; fn++)
+ if (!isalnum(*fn) && !strchr(file_charsAllowedInName, *fn))
+ return(1);
+ return(0);
+}
+
+/*############################################################*/
/* file_pdfname2psname */
/* If the file ends in .pdf, change this to .ps.*/
/* Return pointer to temp copy if changed, else to input string. */