[PATCH] dir: do all size checks before seeking back and fix file closing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Jonas Fonseca <fonseca@xxxxxxx>
---
 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
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]