57 lines
1.2 KiB
Text
57 lines
1.2 KiB
Text
|
$NetBSD: patch-ac,v 1.1.1.1 2001/05/31 10:54:22 agc Exp $
|
||
|
|
||
|
Use mkstemp() in preference to tempnam().
|
||
|
Note use of snprintf(), as not all platforms have strlcpy().
|
||
|
|
||
|
--- biblook.c 2001/05/31 08:55:19 1.1
|
||
|
+++ biblook.c 2001/05/31 09:02:25
|
||
|
@@ -1276,6 +1276,8 @@
|
||
|
putc('\n', ofp);
|
||
|
}
|
||
|
|
||
|
+#include <sys/param.h>
|
||
|
+
|
||
|
/* ----------------------------------------------------------------- *\
|
||
|
| void PrintResults(char *filename)
|
||
|
|
|
||
|
@@ -1288,6 +1290,9 @@
|
||
|
FILE *ofp;
|
||
|
char *pager;
|
||
|
char *the_tmpfile = (char*)NULL;
|
||
|
+#if (defined(BSD) && BSD >= 199306)
|
||
|
+ char f[MAXPATHLEN];
|
||
|
+#endif
|
||
|
#if unix
|
||
|
int childpid;
|
||
|
#else
|
||
|
@@ -1315,8 +1320,19 @@
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
+#if (defined(BSD) && BSD >= 199306)
|
||
|
+ int fd;
|
||
|
+
|
||
|
+ (void) snprintf(f, sizeof(f), "/tmp/bibl.XXXXXX");
|
||
|
+ if ((fd = mkstemp(f)) < 0) {
|
||
|
+ perror("\tCan't open temp file");
|
||
|
+ return;
|
||
|
+ }
|
||
|
+ ofp = fdopen(fd, "w");
|
||
|
+#else
|
||
|
the_tmpfile = (char*)tempnam(NULL, "bibl.");
|
||
|
ofp = fopen(the_tmpfile, "w");
|
||
|
+#endif
|
||
|
if (!ofp)
|
||
|
{
|
||
|
perror("\tCan't open temp file");
|
||
|
@@ -1386,7 +1402,9 @@
|
||
|
#endif
|
||
|
|
||
|
unlink(the_tmpfile);
|
||
|
+#if !(defined(BSD) && BSD >= 199306)
|
||
|
free(the_tmpfile); /* malloc'ed by tempnam() */
|
||
|
+#endif
|
||
|
putchar('\n');
|
||
|
}
|
||
|
}
|