File byacc-1.9-security.patch of Package byacc

--- yacc/main.c.security	Mon Jan 10 15:26:24 2000
+++ yacc/main.c	Fri Jan  5 10:21:29 2001
@@ -109,6 +109,11 @@
 short **derives;
 char *nullable;
 
+#ifdef linux
+# define mktemp		safe_mktemp
+extern void		safe_mktemp(char *tmpl);
+#endif
+
 static void create_file_names __P((void));
 static void getargs __P((int, char **));
 static void onintr __P((int));
@@ -121,9 +126,18 @@
 done(k)
 int k;
 {
-    if (action_file) { fclose(action_file); unlink(action_file_name); }
-    if (text_file) { fclose(text_file); unlink(text_file_name); }
-    if (union_file) { fclose(union_file); unlink(union_file_name); }
+    if (action_file)
+	fclose(action_file);
+    if (action_file_name[0])
+     	unlink(action_file_name);
+    if (text_file)
+	fclose(text_file);
+    if (text_file_name[0])
+     	unlink(text_file_name);
+    if (union_file)
+	fclose(union_file);
+    if (union_file_name[0])
+     	unlink(union_file_name);
     exit(k);
 }
 
@@ -482,6 +496,19 @@
 	code_file = output_file;
 }
 
+#ifdef linux
+void
+safe_mktemp(char *fname)
+{
+    int	fd;
+
+    if ((fd = mkstemp(fname)) < 0) {
+        perror("unable to create temp file");
+	exit(1);
+    }
+    close(fd);
+}
+#endif
 
 int
 main(argc, argv)
openSUSE Build Service is sponsored by