2007-06-26 19:54:53 +00:00
|
|
|
$OpenBSD: patch-source_file_c,v 1.6 2007/06/26 19:54:53 jasper Exp $
|
|
|
|
--- source/file.c.orig Tue Aug 24 11:37:24 2004
|
|
|
|
+++ source/file.c Fri Jun 22 17:30:03 2007
|
|
|
|
@@ -1314,7 +1314,12 @@ void PrintWindow(WindowInfo *window, int selectedOnly)
|
2000-06-09 20:10:30 +00:00
|
|
|
*/
|
2001-10-31 08:03:18 +00:00
|
|
|
void PrintString(const char *string, int length, Widget parent, const char *jobName)
|
2000-06-09 20:10:30 +00:00
|
|
|
{
|
|
|
|
+#ifdef HAVE_MKSTEMP
|
|
|
|
+ static char template[] = "/var/tmp/nedit-XXXXXXXXXX";
|
|
|
|
+ char tmpFileName[sizeof(template)];
|
|
|
|
+#else
|
|
|
|
char tmpFileName[L_tmpnam]; /* L_tmpnam defined in stdio.h */
|
|
|
|
+#endif
|
|
|
|
FILE *fp;
|
2001-10-31 08:03:18 +00:00
|
|
|
int fd;
|
2000-06-09 20:10:30 +00:00
|
|
|
|
2007-06-26 19:54:53 +00:00
|
|
|
@@ -1325,6 +1330,10 @@ void PrintString(const char *string, int length, Widge
|
2001-10-31 08:03:18 +00:00
|
|
|
1. Create a filename
|
|
|
|
2. Open the file with the O_CREAT|O_EXCL flags
|
|
|
|
So all an attacker can do is a DoS on the print function. */
|
2000-06-09 20:10:30 +00:00
|
|
|
+#ifdef HAVE_MKSTEMP
|
|
|
|
+ strcpy(tmpFileName, template);
|
2002-06-13 05:44:57 +00:00
|
|
|
+ if ((fd = mkstemp(tmpFileName)) < 0 || (fp = fdopen(fd, "w")) == NULL)
|
2000-06-09 20:10:30 +00:00
|
|
|
+#else
|
|
|
|
tmpnam(tmpFileName);
|
|
|
|
|
2001-10-31 08:03:18 +00:00
|
|
|
/* open the temporary file */
|
2007-06-26 19:54:53 +00:00
|
|
|
@@ -1333,6 +1342,7 @@ void PrintString(const char *string, int length, Widge
|
2000-06-09 20:10:30 +00:00
|
|
|
#else
|
2002-06-13 05:44:57 +00:00
|
|
|
if ((fd = open(tmpFileName, O_CREAT|O_EXCL|O_WRONLY, S_IRUSR | S_IWUSR)) < 0 || (fp = fdopen(fd, "w")) == NULL)
|
2000-06-09 20:10:30 +00:00
|
|
|
#endif /* VMS */
|
|
|
|
+#endif /* HAVE_MKSTEMP */
|
2002-06-13 05:44:57 +00:00
|
|
|
{
|
2004-01-14 23:42:53 +00:00
|
|
|
DialogF(DF_WARN, parent, 1, "Error while Printing",
|
2004-10-17 21:23:50 +00:00
|
|
|
"Unable to write file for printing:\n%s", "OK",
|