summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorbitblt <bitblt@cvs.openbsd.org>1996-09-28 09:56:55 +0000
committerbitblt <bitblt@cvs.openbsd.org>1996-09-28 09:56:55 +0000
commitd18b3d61981cc91c84975bd3561373ca30914b98 (patch)
treeabe5ed208a8fcc8d56bf121a5e7f7cedeb5f302d /usr.bin
parent190461b0db71c02c4160a2ad4417524983153457 (diff)
the LIST carried out by mget in remglob() no longer follows symbolic links
on its temporary file.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ftp/cmds.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/usr.bin/ftp/cmds.c b/usr.bin/ftp/cmds.c
index 7043c7155a7..e7d458df730 100644
--- a/usr.bin/ftp/cmds.c
+++ b/usr.bin/ftp/cmds.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmds.c,v 1.4 1996/09/16 02:26:06 deraadt Exp $ */
+/* $OpenBSD: cmds.c,v 1.5 1996/09/28 09:56:54 bitblt Exp $ */
/* $NetBSD: cmds.c,v 1.8 1995/09/08 01:06:05 tls Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94";
#else
-static char rcsid[] = "$OpenBSD: cmds.c,v 1.4 1996/09/16 02:26:06 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: cmds.c,v 1.5 1996/09/28 09:56:54 bitblt Exp $";
#endif
#endif /* not lint */
@@ -62,6 +62,7 @@ static char rcsid[] = "$OpenBSD: cmds.c,v 1.4 1996/09/16 02:26:06 deraadt Exp $"
#include <string.h>
#include <time.h>
#include <unistd.h>
+#include <fcntl.h>
#include "ftp_var.h"
#include "pathnames.h"
@@ -782,6 +783,7 @@ remglob(argv,doswitch)
char temp[16];
static char buf[MAXPATHLEN];
static FILE *ftemp = NULL;
+ int fd;
static char **args;
int oldverbose, oldhash;
char *cp, *mode;
@@ -808,6 +810,16 @@ remglob(argv,doswitch)
if (ftemp == NULL) {
(void) strcpy(temp, _PATH_TMPFILE);
(void) mktemp(temp);
+ /* create a zero-byte version of the file so that
+ * people can't play symlink games.
+ */
+ fd = open (temp, O_CREAT | O_EXCL | O_WRONLY, 600);
+ if (fd < 0) {
+ printf ("temporary file %s already exists\n",temp);
+ close (fd);
+ return NULL;
+ }
+ close (fd);
oldverbose = verbose, verbose = 0;
oldhash = hash, hash = 0;
if (doswitch) {