diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-11-11 01:12:11 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-11-11 01:12:11 +0000 |
commit | df8ebf4c4a153005ea56888d82e05288c597b4dc (patch) | |
tree | c0eb870a47c4f73e3880ed05eb2ca1d61294ea89 | |
parent | 4a35cd787d4211704bc33e641f746562a95af113 (diff) |
creat() -> open equiv; from Frederic Nowak
-rw-r--r-- | games/backgammon/common_source/save.c | 10 | ||||
-rw-r--r-- | games/hack/hack.bones.c | 4 | ||||
-rw-r--r-- | games/hack/hack.do.c | 4 | ||||
-rw-r--r-- | games/hack/hack.save.c | 6 | ||||
-rw-r--r-- | games/hack/hack.unix.c | 4 | ||||
-rw-r--r-- | games/mille/save.c | 4 | ||||
-rw-r--r-- | games/trek/dumpgame.c | 4 | ||||
-rw-r--r-- | lib/libutil/uucplock.c | 4 | ||||
-rw-r--r-- | usr.bin/indent/indent.c | 4 | ||||
-rw-r--r-- | usr.bin/mail/quit.c | 4 | ||||
-rw-r--r-- | usr.bin/mail/v7.local.c | 4 | ||||
-rw-r--r-- | usr.bin/patch/inp.c | 4 | ||||
-rw-r--r-- | usr.bin/tftp/main.c | 6 |
13 files changed, 33 insertions, 29 deletions
diff --git a/games/backgammon/common_source/save.c b/games/backgammon/common_source/save.c index 74b54b64f9b..1e09e0f7dce 100644 --- a/games/backgammon/common_source/save.c +++ b/games/backgammon/common_source/save.c @@ -1,4 +1,4 @@ -/* $OpenBSD: save.c,v 1.12 2015/06/26 19:18:03 otto Exp $ */ +/* $OpenBSD: save.c,v 1.13 2015/11/11 01:12:10 deraadt Exp $ */ /* * Copyright (c) 1980, 1993 @@ -86,7 +86,9 @@ save(n) } *fs = '\0'; if ((fdesc = open(fname, O_RDWR)) == -1 && errno == ENOENT) { - if ((fdesc = creat(fname, 0600)) != -1) + if ((fdesc = open(fname, + O_CREAT | O_TRUNC | O_WRONLY, + 0600)) != -1) break; } if (fdesc != -1) { @@ -97,7 +99,9 @@ save(n) close(fdesc); if (yorn(0)) { unlink(fname); - fdesc = creat(fname, 0600); + fdesc = open(fname, + O_CREAT | O_TRUNC | O_WRONLY, + 0600); break; } else { cflag = 1; diff --git a/games/hack/hack.bones.c b/games/hack/hack.bones.c index 6cd76829f1b..9c93b813ab7 100644 --- a/games/hack/hack.bones.c +++ b/games/hack/hack.bones.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hack.bones.c,v 1.8 2009/10/27 23:59:25 deraadt Exp $ */ +/* $OpenBSD: hack.bones.c,v 1.9 2015/11/11 01:12:10 deraadt Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, @@ -129,7 +129,7 @@ savebones() otmp->cursed = 1; /* flag as gotten from a ghost */ } } - if((fd = creat(bones, FMASK)) < 0) return; + if((fd = open(bones, O_CREAT | O_TRUNC | O_WRONLY, FMASK)) < 0) return; savelev(fd,dlevel); (void) close(fd); } diff --git a/games/hack/hack.do.c b/games/hack/hack.do.c index e74f0747bc9..8b2457cd8b1 100644 --- a/games/hack/hack.do.c +++ b/games/hack/hack.do.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hack.do.c,v 1.8 2014/03/11 08:05:15 guenther Exp $ */ +/* $OpenBSD: hack.do.c,v 1.9 2015/11/11 01:12:10 deraadt Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, @@ -193,7 +193,7 @@ goto_level(int newlevel, boolean at_stairs) if(newlevel == dlevel) return; /* this can happen */ glo(dlevel); - fd = creat(lock, FMASK); + fd = open(lock, O_CREAT | O_TRUNC | O_WRONLY, FMASK); if(fd < 0) { /* * This is not quite impossible: e.g., we may have diff --git a/games/hack/hack.save.c b/games/hack/hack.save.c index e31b2b2d1f4..481cecede80 100644 --- a/games/hack/hack.save.c +++ b/games/hack/hack.save.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hack.save.c,v 1.11 2014/03/11 08:05:15 guenther Exp $ */ +/* $OpenBSD: hack.save.c,v 1.12 2015/11/11 01:12:10 deraadt Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, @@ -100,7 +100,7 @@ dosave0(int hu) (void) signal(SIGHUP, SIG_IGN); (void) signal(SIGINT, SIG_IGN); - if((fd = creat(SAVEF, FMASK)) < 0) { + if((fd = open(SAVEF, O_CREAT | O_TRUNC | O_WRONLY, FMASK)) < 0) { if(!hu) pline("Cannot open save file. (Continue or Quit)"); (void) unlink(SAVEF); /* ab@unido */ return(0); @@ -192,7 +192,7 @@ dorecover(int fd) break; getlev(fd, 0, tmp); glo(tmp); - if((nfd = creat(lock, FMASK)) < 0) + if((nfd = open(lock, O_CREAT | O_TRUNC | O_WRONLY, FMASK)) < 0) panic("Cannot open temp file %s!\n", lock); savelev(nfd,tmp); (void) close(nfd); diff --git a/games/hack/hack.unix.c b/games/hack/hack.unix.c index 18502de172c..f0eef097307 100644 --- a/games/hack/hack.unix.c +++ b/games/hack/hack.unix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hack.unix.c,v 1.15 2014/11/16 04:49:48 guenther Exp $ */ +/* $OpenBSD: hack.unix.c,v 1.16 2015/11/11 01:12:10 deraadt Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, @@ -286,7 +286,7 @@ getlock() error(locknum ? "Too many hacks running now." : "There is a game in progress under your name."); gotlock: - fd = creat(lock, FMASK); + fd = open(lock, O_CREAT | O_TRUNC | O_WRONLY, FMASK); if(unlink(LLOCK) == -1) error("Cannot unlink %s.", LLOCK); if(fd == -1) { diff --git a/games/mille/save.c b/games/mille/save.c index 9d44ca32580..b699fe3bfb8 100644 --- a/games/mille/save.c +++ b/games/mille/save.c @@ -1,4 +1,4 @@ -/* $OpenBSD: save.c,v 1.8 2009/10/27 23:59:26 deraadt Exp $ */ +/* $OpenBSD: save.c,v 1.9 2015/11/11 01:12:10 deraadt Exp $ */ /* $NetBSD: save.c,v 1.4 1995/03/24 05:02:13 cgd Exp $ */ /* @@ -100,7 +100,7 @@ over: && getyn(OVERWRITEFILEPROMPT) == FALSE)) return FALSE; - if ((outf = creat(buf, 0644)) < 0) { + if ((outf = open(buf, O_CREAT | O_TRUNC | O_WRONLY, 0644)) < 0) { error(strerror(errno)); return FALSE; } diff --git a/games/trek/dumpgame.c b/games/trek/dumpgame.c index ea8971c40b6..4ea4a09995c 100644 --- a/games/trek/dumpgame.c +++ b/games/trek/dumpgame.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dumpgame.c,v 1.9 2009/10/27 23:59:27 deraadt Exp $ */ +/* $OpenBSD: dumpgame.c,v 1.10 2015/11/11 01:12:10 deraadt Exp $ */ /* $NetBSD: dumpgame.c,v 1.4 1995/04/24 12:25:54 cgd Exp $ */ /* @@ -81,7 +81,7 @@ dumpgame(v) struct dump *d; int i; - if ((fd = creat("trek.dump", 0644)) < 0) + if ((fd = open("trek.dump", O_CREAT | O_TRUNC | O_WRONLY, 0644)) < 0) { warn("cannot open `trek.dump'"); return; diff --git a/lib/libutil/uucplock.c b/lib/libutil/uucplock.c index 0c10f8cced0..f62273c8f9f 100644 --- a/lib/libutil/uucplock.c +++ b/lib/libutil/uucplock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uucplock.c,v 1.16 2009/10/27 23:59:30 deraadt Exp $ */ +/* $OpenBSD: uucplock.c,v 1.17 2015/11/11 01:12:09 deraadt Exp $ */ /* * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. @@ -70,7 +70,7 @@ uu_lock(const char *ttyname) (long)pid); (void)snprintf(lckname, sizeof(lckname), _PATH_UUCPLOCK LOCKFMT, ttyname); - if ((tmpfd = creat(lcktmpname, 0664)) < 0) + if ((tmpfd = open(lcktmpname, O_CREAT | O_TRUNC | O_WRONLY, 0664)) < 0) GORET(0, UU_LOCK_CREAT_ERR); for (i = 0; i < MAXTRIES; i++) { diff --git a/usr.bin/indent/indent.c b/usr.bin/indent/indent.c index 13ff0d2e887..951f03f5442 100644 --- a/usr.bin/indent/indent.c +++ b/usr.bin/indent/indent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: indent.c,v 1.29 2015/10/09 01:37:07 deraadt Exp $ */ +/* $OpenBSD: indent.c,v 1.30 2015/11/11 01:12:09 deraadt Exp $ */ /* * Copyright (c) 1980, 1993 @@ -1184,7 +1184,7 @@ bakcopy(void) errc(1, ENAMETOOLONG, "%s.BAK", p); /* copy in_name to backup file */ - bakchn = creat(bakfile, 0600); + bakchn = open(bakfile, O_CREAT | O_TRUNC | O_WRONLY, 0600); if (bakchn < 0) err(1, "%s", bakfile); while ((n = read(fileno(input), buff, sizeof buff)) > 0) diff --git a/usr.bin/mail/quit.c b/usr.bin/mail/quit.c index 56216375b1a..29109ed148e 100644 --- a/usr.bin/mail/quit.c +++ b/usr.bin/mail/quit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: quit.c,v 1.21 2014/11/24 20:01:43 millert Exp $ */ +/* $OpenBSD: quit.c,v 1.22 2015/11/11 01:12:10 deraadt Exp $ */ /* $NetBSD: quit.c,v 1.6 1996/12/28 07:11:07 tls Exp $ */ /* @@ -220,7 +220,7 @@ quit(void) return(-1); } (void)Fclose(obuf); - (void)close(creat(mbox, 0600)); + (void)close(open(mbox, O_CREAT | O_TRUNC | O_WRONLY, 0600)); if ((obuf = Fopen(mbox, "r+")) == NULL) { warn("%s", mbox); (void)Fclose(ibuf); diff --git a/usr.bin/mail/v7.local.c b/usr.bin/mail/v7.local.c index dd10018ff53..91e9526763b 100644 --- a/usr.bin/mail/v7.local.c +++ b/usr.bin/mail/v7.local.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v7.local.c,v 1.15 2009/10/27 23:59:40 deraadt Exp $ */ +/* $OpenBSD: v7.local.c,v 1.16 2015/11/11 01:12:10 deraadt Exp $ */ /* $NetBSD: v7.local.c,v 1.8 1997/05/13 06:15:58 mikel Exp $ */ /* @@ -72,7 +72,7 @@ demail(void) { if (value("keep") != NULL || rm(mailname) < 0) - (void)close(creat(mailname, 0600)); + (void)close(open(mailname, O_CREAT | O_TRUNC | O_WRONLY, 0600)); } /* diff --git a/usr.bin/patch/inp.c b/usr.bin/patch/inp.c index 99194a4ac14..6606ede551f 100644 --- a/usr.bin/patch/inp.c +++ b/usr.bin/patch/inp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inp.c,v 1.44 2015/07/26 14:32:19 millert Exp $ */ +/* $OpenBSD: inp.c,v 1.45 2015/11/11 01:12:10 deraadt Exp $ */ /* * patch - a program to apply diffs to original files @@ -159,7 +159,7 @@ plan_a(const char *filename) if (check_only) return true; makedirs(filename, true); - close(creat(filename, 0666)); + close(open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0666)); statfailed = stat(filename, &filestat); } if (statfailed) diff --git a/usr.bin/tftp/main.c b/usr.bin/tftp/main.c index eaeaefdac3e..e653b8aefcf 100644 --- a/usr.bin/tftp/main.c +++ b/usr.bin/tftp/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.38 2015/10/18 03:54:22 deraadt Exp $ */ +/* $OpenBSD: main.c,v 1.39 2015/11/11 01:12:10 deraadt Exp $ */ /* $NetBSD: main.c,v 1.6 1995/05/21 16:54:10 mycroft Exp $ */ /* @@ -473,7 +473,7 @@ get(int argc, char *argv[]) } if (argc < 4) { cp = argc == 3 ? argv[2] : tail(src); - fd = creat(cp, 0644); + fd = open(cp, O_CREAT | O_TRUNC | O_WRONLY, 0644); if (fd < 0) { warn("create: %s", cp); return; @@ -485,7 +485,7 @@ get(int argc, char *argv[]) break; } cp = tail(src); /* new .. jdg */ - fd = creat(cp, 0644); + fd = open(cp, O_CREAT | O_TRUNC | O_WRONLY, 0644); if (fd < 0) { warn("create: %s", cp); continue; |