From: Jonas Fonseca <fonseca@diku.dk>
To: git@vger.kernel.org
Subject: [PATCH] dir: do all size checks before seeking back and fix file closing
Date: Sat, 26 Aug 2006 16:17:09 +0200 [thread overview]
Message-ID: <20060826141709.GC11601@diku.dk> (raw)
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
dir.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/dir.c b/dir.c
index d53d48f..ff8a2fb 100644
--- a/dir.c
+++ b/dir.c
@@ -122,11 +122,11 @@ static int add_excludes_from_file_1(cons
size = lseek(fd, 0, SEEK_END);
if (size < 0)
goto err;
- lseek(fd, 0, SEEK_SET);
if (size == 0) {
close(fd);
return 0;
}
+ lseek(fd, 0, SEEK_SET);
buf = xmalloc(size+1);
if (read(fd, buf, size) != size)
goto err;
@@ -146,7 +146,7 @@ static int add_excludes_from_file_1(cons
return 0;
err:
- if (0 <= fd)
+ if (0 >= fd)
close(fd);
return -1;
}
--
1.4.2.GIT
--
Jonas Fonseca
next reply other threads:[~2006-08-26 14:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-26 14:17 Jonas Fonseca [this message]
2006-08-26 18:43 ` [PATCH] dir: do all size checks before seeking back and fix file closing Mitchell Blank Jr
2006-08-26 20:44 ` Jonas Fonseca
2006-08-26 22:13 ` Linus Torvalds
2006-08-26 22:35 ` Jakub Narebski
2006-08-27 0:07 ` Junio C Hamano
2006-08-27 2:15 ` Junio C Hamano
2006-08-27 2:37 ` Linus Torvalds
2006-08-27 3:04 ` Junio C Hamano
2006-08-27 23:55 ` [PATCH] Use fstat instead of fseek Jonas Fonseca
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060826141709.GC11601@diku.dk \
--to=fonseca@diku.dk \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).