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/rcsmerge.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/rcsmerge.c')
-rw-r--r-- | usr.bin/rcs/rcsmerge.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/usr.bin/rcs/rcsmerge.c b/usr.bin/rcs/rcsmerge.c index 9335838e503..e4eadf8167b 100644 --- a/usr.bin/rcs/rcsmerge.c +++ b/usr.bin/rcs/rcsmerge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsmerge.c,v 1.36 2006/04/26 02:55:13 joris Exp $ */ +/* $OpenBSD: rcsmerge.c,v 1.37 2006/04/26 21:55:22 joris Exp $ */ /* * Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org> * All rights reserved. @@ -32,7 +32,7 @@ int rcsmerge_main(int argc, char **argv) { - int i, ch, flags, kflag; + int fd, i, ch, flags, kflag; char *fcont, fpath[MAXPATHLEN], r1[16], r2[16], *rev_str1, *rev_str2; RCSFILE *file; RCSNUM *rev1, *rev2; @@ -105,10 +105,11 @@ rcsmerge_main(int argc, char **argv) } for (i = 0; i < argc; i++) { - if (rcs_statfile(argv[i], fpath, sizeof(fpath), flags) < 0) + fd = rcs_statfile(argv[i], fpath, sizeof(fpath), flags); + if (fd < 0) continue; - if ((file = rcs_open(fpath, RCS_READ)) == NULL) + if ((file = rcs_open(fpath, fd, RCS_READ)) == NULL) continue; if (!(flags & QUIET)) |