mirror of
https://github.com/Stichting-MINIX-Research-Foundation/pkgsrc-ng.git
synced 2025-08-04 02:08:49 -04:00
69 lines
1.6 KiB
Plaintext
69 lines
1.6 KiB
Plaintext
$NetBSD: patch-ab,v 1.9 2012/01/10 21:09:55 tez Exp $
|
|
|
|
- Include fixes for modern Unix.
|
|
- Don't try to use /usr/tmp.
|
|
- Time handling fixes for NetBSD with 64-bit time_t.
|
|
- Fix for CVE-2011-4919 (bad permissions on created files)
|
|
|
|
Upstream: as far as I know not actively maintained upstream.
|
|
|
|
--- unixos.c.orig 2003-07-21 20:54:05.000000000 +0000
|
|
+++ unixos.c
|
|
@@ -23,9 +23,11 @@
|
|
* SOFTWARE.
|
|
*/
|
|
#include <stdio.h>
|
|
+#include <stdlib.h>
|
|
#include <ctype.h>
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
+#include <time.h>
|
|
#include <sys/types.h>
|
|
#include <sys/param.h>
|
|
#include <netdb.h>
|
|
@@ -38,10 +40,6 @@
|
|
#define MAXHOSTNAMELEN 64
|
|
#endif
|
|
|
|
-extern int errno;
|
|
-extern char *malloc();
|
|
-extern char *getenv();
|
|
-
|
|
int overwrite_files = 0;
|
|
int didchat;
|
|
|
|
@@ -76,7 +74,7 @@ char *os_genid(void)
|
|
}
|
|
|
|
result = malloc(25+strlen(hostname));
|
|
- sprintf(result, "%d.%d@%s", pid, curtime++, hostname);
|
|
+ sprintf(result, "%d.%lld@%s", pid, (long long) curtime++, hostname);
|
|
return result;
|
|
}
|
|
|
|
@@ -90,7 +88,11 @@ char *os_idtodir(char *id)
|
|
strcpy(buf, getenv("TMPDIR"));
|
|
}
|
|
else {
|
|
- strcpy(buf, "/usr/tmp");
|
|
+#if defined(P_tmpdir)
|
|
+ strcpy(buf, P_tmpdir);
|
|
+#else
|
|
+ strcpy(buf, "/var/tmp");
|
|
+#endif
|
|
}
|
|
strcat(buf, "/m-prts-");
|
|
p = getenv("USER");
|
|
@@ -137,9 +139,9 @@ FILE *os_createnewfile(char *fname)
|
|
FILE *ret;
|
|
|
|
#ifdef O_EXCL
|
|
- fd=open(fname, O_RDWR|O_CREAT|O_EXCL, 0644);
|
|
+ fd=open(fname, O_RDWR|O_CREAT|O_EXCL, 0600);
|
|
#else
|
|
- fd=open(fname, O_RDWR|O_CREAT|O_TRUNC, 0644);
|
|
+ fd=open(fname, O_RDWR|O_CREAT|O_TRUNC, 0600);
|
|
#endif
|
|
|
|
if (fd == -1)
|