41ed53ba17
- recognise PNG files and set appropriate mime type (from FreeBSD). - remove botched mkstemp() conversion which broke mpack(1); a proper mkstemp conversion is intrusive. - use some additional XXXX in the temporary filename. - let this build with CLang scan-build.
69 lines
1.4 KiB
Plaintext
69 lines
1.4 KiB
Plaintext
$OpenBSD: patch-unixos_c,v 1.6 2012/12/11 11:01:31 sthen Exp $
|
|
|
|
Fixes from Sebastian Pipping/gentoo.
|
|
|
|
--- unixos.c.orig Mon Jul 21 21:54:05 2003
|
|
+++ unixos.c Tue Dec 11 10:52:04 2012
|
|
@@ -30,6 +30,7 @@
|
|
#include <sys/param.h>
|
|
#include <netdb.h>
|
|
#include <fcntl.h>
|
|
+#include <stdlib.h>
|
|
#include "xmalloc.h"
|
|
#include "common.h"
|
|
#include "part.h"
|
|
@@ -38,10 +39,6 @@
|
|
#define MAXHOSTNAMELEN 64
|
|
#endif
|
|
|
|
-extern int errno;
|
|
-extern char *malloc();
|
|
-extern char *getenv();
|
|
-
|
|
int overwrite_files = 0;
|
|
int didchat;
|
|
|
|
@@ -90,7 +87,7 @@ char *os_idtodir(char *id)
|
|
strcpy(buf, getenv("TMPDIR"));
|
|
}
|
|
else {
|
|
- strcpy(buf, "/usr/tmp");
|
|
+ strcpy(buf, "/var/tmp");
|
|
}
|
|
strcat(buf, "/m-prts-");
|
|
p = getenv("USER");
|
|
@@ -136,11 +133,7 @@ FILE *os_createnewfile(char *fname)
|
|
int fd;
|
|
FILE *ret;
|
|
|
|
-#ifdef O_EXCL
|
|
- fd=open(fname, O_RDWR|O_CREAT|O_EXCL, 0644);
|
|
-#else
|
|
- fd=open(fname, O_RDWR|O_CREAT|O_TRUNC, 0644);
|
|
-#endif
|
|
+ fd=open(fname, O_RDWR|O_CREAT|O_EXCL, 0600);
|
|
|
|
if (fd == -1)
|
|
return NULL;
|
|
@@ -149,7 +142,19 @@ FILE *os_createnewfile(char *fname)
|
|
return ret;
|
|
}
|
|
|
|
-
|
|
+FILE *os_resetfile(char *fname)
|
|
+{
|
|
+ int fd;
|
|
+ FILE *ret;
|
|
+
|
|
+ fd=open(fname, O_RDWR|O_CREAT|O_TRUNC, 0600);
|
|
+ if (fd == -1)
|
|
+ return NULL;
|
|
+
|
|
+ ret=fdopen(fd, "w");
|
|
+ return ret;
|
|
+}
|
|
+
|
|
/*
|
|
* Create a new file, with suggested filename "fname".
|
|
* "fname" may have come from an insecure source, so clean it up first.
|