From: Jonas Fonseca Date: Sat, 26 Aug 2006 14:17:09 GMT Subject: [PATCH] dir: do all size checks before seeking back and fix file closing Message-ID: <20060826141709.GC11601@diku.dk> Signed-off-by: Jonas Fonseca --- 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