openbsd-ports/devel/ddd/patches/patch-ddd_show_C
espie 5c56db06a3 Fix tmpnam() holes in ddd.
Quick and dirty patches that do the job, a cleaner version
to contribute back to ddd's authors will appear shortly.
2000-10-30 13:54:50 +00:00

29 lines
782 B
Plaintext

$OpenBSD: patch-ddd_show_C,v 1.1 2000/10/30 13:54:51 espie Exp $
--- ddd/show.C.orig Mon Oct 30 13:39:23 2000
+++ ddd/show.C Mon Oct 30 13:40:48 2000
@@ -57,6 +57,7 @@ char show_rcsid[] =
#include <fstream.h>
#include <string.h>
#include <errno.h>
+#include <unistd.h>
#include "Xpm.h"
#include "HelpCB.h"
@@ -372,11 +373,14 @@ void show_configuration(ostream& os)
static int uncompress(ostream& os, const char *text, int size)
{
- string tempfile = tmpnam(0);
- FILE *fp = fopen(tempfile, "w");
+ char temp_name[] = "/tmp/ddd.XXXXXXXXXX";
+ int temp_fd = mkstemp(temp_name);
+ string tempfile = temp_name;
+ FILE *fp = fdopen(temp_fd, "w");
if (fp == 0)
{
os << tempfile << ": " << strerror(errno);
+ close(temp_fd);
return -1;
}