diff options
author | 2004-08-27 12:42:45 +0000 | |
---|---|---|
committer | 2004-08-27 12:42:45 +0000 | |
commit | 1a38aa3cc7028bd0cd5f72abb13426deda1fe29f (patch) | |
tree | b80ccf60c434cc2fe2b3e7c603f29dc1da679114 | |
parent | correct emacs version; free commit sponsored by theo and miod (diff) | |
download | wireguard-openbsd-1a38aa3cc7028bd0cd5f72abb13426deda1fe29f.tar.xz wireguard-openbsd-1a38aa3cc7028bd0cd5f72abb13426deda1fe29f.zip |
Fix two descriptor leaks
-rw-r--r-- | usr.bin/cvs/proto.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/usr.bin/cvs/proto.c b/usr.bin/cvs/proto.c index 5e9eff482ab..66a6535282c 100644 --- a/usr.bin/cvs/proto.c +++ b/usr.bin/cvs/proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proto.c,v 1.23 2004/08/13 02:57:28 jfb Exp $ */ +/* $OpenBSD: proto.c,v 1.24 2004/08/27 12:42:45 jfb Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -551,20 +551,21 @@ cvs_sendfile(struct cvsroot *root, const char *path) return (-1); } + if (cvs_modetostr(st.st_mode, buf, sizeof(buf)) < 0) + return (-1); + fd = open(path, O_RDONLY, 0); if (fd == -1) { return (-1); } - if (cvs_modetostr(st.st_mode, buf, sizeof(buf)) < 0) - return (-1); - cvs_sendln(root, buf); snprintf(buf, sizeof(buf), "%lld\n", st.st_size); cvs_sendln(root, buf); while ((ret = read(fd, buf, sizeof(buf))) != 0) { if (ret == -1) { + (void)close(fd); cvs_log(LP_ERRNO, "failed to read file `%s'", path); return (-1); } |