1 $NetBSD: patch-ab,v 1.9 2012/01/10 21:09:55 tez Exp $
3 - Include fixes for modern Unix.
4 - Don't try to use /usr/tmp.
5 - Time handling fixes for NetBSD with 64-bit time_t.
6 - Fix for CVE-2011-4919 (bad permissions on created files)
8 Upstream: as far as I know not actively maintained upstream.
10 --- unixos.c.orig 2003-07-21 20:54:05.000000000 +0000
21 #include <sys/types.h>
22 #include <sys/param.h>
25 #define MAXHOSTNAMELEN 64
29 -extern char *malloc();
30 -extern char *getenv();
32 int overwrite_files = 0;
35 @@ -76,7 +74,7 @@ char *os_genid(void)
38 result = malloc(25+strlen(hostname));
39 - sprintf(result, "%d.%d@%s", pid, curtime++, hostname);
40 + sprintf(result, "%d.%lld@%s", pid, (long long) curtime++, hostname);
44 @@ -90,7 +88,11 @@ char *os_idtodir(char *id)
45 strcpy(buf, getenv("TMPDIR"));
48 - strcpy(buf, "/usr/tmp");
49 +#if defined(P_tmpdir)
50 + strcpy(buf, P_tmpdir);
52 + strcpy(buf, "/var/tmp");
55 strcat(buf, "/m-prts-");
57 @@ -137,9 +139,9 @@ FILE *os_createnewfile(char *fname)
61 - fd=open(fname, O_RDWR|O_CREAT|O_EXCL, 0644);
62 + fd=open(fname, O_RDWR|O_CREAT|O_EXCL, 0600);
64 - fd=open(fname, O_RDWR|O_CREAT|O_TRUNC, 0644);
65 + fd=open(fname, O_RDWR|O_CREAT|O_TRUNC, 0600);