diff options
author | Joris Vink <joris@cvs.openbsd.org> | 2008-02-27 22:34:05 +0000 |
---|---|---|
committer | Joris Vink <joris@cvs.openbsd.org> | 2008-02-27 22:34:05 +0000 |
commit | c8955619dd8db636823797d2bd41b68bc78af8c1 (patch) | |
tree | 0f1a922b9d1b4bb083ea6b7477f91aaa7333681d /usr.bin/cvs/buf.c | |
parent | 3d3b75f61b57504b71451e352de59d6ff8ffd6a4 (diff) |
prevent file races
ok tobias@
Diffstat (limited to 'usr.bin/cvs/buf.c')
-rw-r--r-- | usr.bin/cvs/buf.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.bin/cvs/buf.c b/usr.bin/cvs/buf.c index 9a1865db156..266199d9ee7 100644 --- a/usr.bin/cvs/buf.c +++ b/usr.bin/cvs/buf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buf.c,v 1.68 2008/02/11 20:33:10 tobias Exp $ */ +/* $OpenBSD: buf.c,v 1.69 2008/02/27 22:34:04 joris Exp $ */ /* * Copyright (c) 2003 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -276,7 +276,7 @@ cvs_buf_write(BUF *b, const char *path, mode_t mode) * specified using <template> (see mkstemp.3). NB. This function will modify * <template>, as per mkstemp */ -void +int cvs_buf_write_stmp(BUF *b, char *template, struct timeval *tv) { int fd; @@ -294,9 +294,12 @@ cvs_buf_write_stmp(BUF *b, char *template, struct timeval *tv) fatal("cvs_buf_write_stmp: futimes failed"); } - (void)close(fd); - cvs_worklist_add(template, &temp_files); + + if (lseek(fd, SEEK_SET, 0) < 0) + fatal("cvs_buf_write_stmp: lseek: %s", strerror(errno)); + + return (fd); } /* |