naddy 78b1720bcc SECURITY fixes, submitted by Nick Nauwelaerts <nick@wanadoo.be>:
* Fix buffer overflow.  (Obtained from Debian)
* Strip leading "../" when creating new files.  (Obtained from Debian)

Clean-up by yours truly:

* Parameter parsing fix.  (Obtained from Debian)
* Prefer native getopt() and MD5 functions over the included ones.
* Make munpack synopsis agree with actual parameters.
* Respect CC.
2002-08-09 01:15:19 +00:00

35 lines
907 B
Plaintext

$OpenBSD: patch-unixos_c,v 1.1 2002/08/09 01:15:19 naddy Exp $
--- unixos.c.orig Thu Feb 16 22:39:50 1995
+++ unixos.c Fri Aug 9 02:58:47 2002
@@ -36,7 +36,9 @@
#define MAXHOSTNAMELEN 64
#endif
+#ifndef errno
extern int errno;
+#endif
extern char *malloc();
extern char *getenv();
@@ -89,7 +91,7 @@ char *id;
strcpy(buf, getenv("TMPDIR"));
}
else {
- strcpy(buf, "/usr/tmp");
+ strcpy(buf, "/var/tmp");
}
strcat(buf, "/m-prts-");
p = getenv("USER");
@@ -159,6 +161,11 @@ params contentParams;
/* Get rid of leading ~ or ~/ */
while (*fname == '~' || *fname == '/') fname++;
+
+ /* Debian fix: the loop below handles internal "/../" but not
+ * leading "../" */
+ /* Get rid of leading "../" */
+ while (!strncmp(fname, "../", 3)) fname += 3;
/* Clean out bad characters, create directories along path */
for (p=fname; *p; p++) {