diff options
author | Joris Vink <joris@cvs.openbsd.org> | 2006-04-26 21:55:23 +0000 |
---|---|---|
committer | Joris Vink <joris@cvs.openbsd.org> | 2006-04-26 21:55:23 +0000 |
commit | df3a4e509cd581d1f7a20e485d02335219e83daf (patch) | |
tree | 624a5f81ee4938e5d6e948c5b9864f1921dcfcf4 /usr.bin/rcs/rlog.c | |
parent | 3822e490767df6f6d16147268ba0f10c37a1e54c (diff) |
prevent file races by obtaining an fd for the RCS file and
do our operations on that, this is safe and guarantees we
can operate on the file until we close(2) it.
a fix is coming for the remaining races in our diff code.
okay niallo@ and ray@
Diffstat (limited to 'usr.bin/rcs/rlog.c')
-rw-r--r-- | usr.bin/rcs/rlog.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.bin/rcs/rlog.c b/usr.bin/rcs/rlog.c index 4fb1c917274..d19ccbd9cc7 100644 --- a/usr.bin/rcs/rlog.c +++ b/usr.bin/rcs/rlog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rlog.c,v 1.51 2006/04/26 02:55:13 joris Exp $ */ +/* $OpenBSD: rlog.c,v 1.52 2006/04/26 21:55:22 joris Exp $ */ /* * Copyright (c) 2005 Joris Vink <joris@openbsd.org> * Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org> @@ -58,7 +58,7 @@ rlog_main(int argc, char **argv) { RCSFILE *file; int Rflag; - int i, ch; + int i, ch, fd; char fpath[MAXPATHLEN]; rcsnum_flags |= RCSNUM_NO_MAGIC; @@ -137,10 +137,12 @@ rlog_main(int argc, char **argv) } for (i = 0; i < argc; i++) { - if (rcs_statfile(argv[i], fpath, sizeof(fpath), 0) < 0) + fd = rcs_statfile(argv[i], fpath, sizeof(fpath), 0); + if (fd < 0) continue; - if ((file = rcs_open(fpath, RCS_READ|RCS_PARSE_FULLY)) == NULL) + if ((file = rcs_open(fpath, fd, + RCS_READ|RCS_PARSE_FULLY)) == NULL) continue; if (Lflag == 1 && TAILQ_EMPTY(&(file->rf_locks))) { |