diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1999-06-23 17:01:37 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1999-06-23 17:01:37 +0000 |
commit | e31de27bd071885215b8c8cd4993523f6973f134 (patch) | |
tree | 91ba04385df828dcabfa7c74f59d31fd84713bfe /libexec | |
parent | b244ab165683014b7e2a1059e5103ca72e7d3270 (diff) |
solve a file creation race
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/tftpd/tftpd.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/libexec/tftpd/tftpd.c b/libexec/tftpd/tftpd.c index f41dff67440..fc6df193cd0 100644 --- a/libexec/tftpd/tftpd.c +++ b/libexec/tftpd/tftpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tftpd.c,v 1.12 1998/07/10 08:06:26 deraadt Exp $ */ +/* $OpenBSD: tftpd.c,v 1.13 1999/06/23 17:01:36 deraadt Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. @@ -41,7 +41,7 @@ char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)tftpd.c 5.13 (Berkeley) 2/26/91";*/ -static char rcsid[] = "$OpenBSD: tftpd.c,v 1.12 1998/07/10 08:06:26 deraadt Exp $: tftpd.c,v 1.6 1997/02/16 23:49:21 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: tftpd.c,v 1.13 1999/06/23 17:01:36 deraadt Exp $: tftpd.c,v 1.6 1997/02/16 23:49:21 deraadt Exp $"; #endif /* not lint */ /* @@ -367,7 +367,7 @@ validate_access(filename, mode) return (errno == ENOENT ? ENOTFOUND : EACCESS); else { if ((errno == ENOENT) && (mode != RRQ)) - wmode = O_CREAT; + wmode |= O_CREAT; else return(EACCESS); } @@ -380,13 +380,13 @@ validate_access(filename, mode) return (EACCESS); } } - fd = open(filename, mode == RRQ ? O_RDONLY : (O_WRONLY|wmode)); + fd = open(filename, mode == RRQ ? O_RDONLY : (O_WRONLY|wmode), 0666); if (fd < 0) return (errno + 100); /* * If the file was created, set default permissions. */ - if ((wmode == O_CREAT) && fchmod(fd, 0666) < 0) { + if ((wmode & O_CREAT) && fchmod(fd, 0666) < 0) { int serrno = errno; close(fd); |