]> Devi Nivas Git - cs3210-lab1.git/commitdiff
Fix unsigned conversion bug.
authorPeter H. Froehlich <peter.hans.froehlich@gmail.com>
Tue, 27 Sep 2016 20:58:29 +0000 (16:58 -0400)
committerFrans Kaashoek <kaashoek@mit.edu>
Tue, 31 Jan 2017 00:31:24 +0000 (19:31 -0500)
Since readi() returns -1 for errors, checking with < against an unsigned
value is inadvisable. Checking with != works as intended however.

exec.c

diff --git a/exec.c b/exec.c
index 6be6af1bc42d7cb67e2d7866a08429f666ef4e39..4d7d97cc8faca8b7288d64e9e15f9708e0d00929 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -28,7 +28,7 @@ exec(char *path, char **argv)
   pgdir = 0;
 
   // Check ELF header
-  if(readi(ip, (char*)&elf, 0, sizeof(elf)) < sizeof(elf))
+  if(readi(ip, (char*)&elf, 0, sizeof(elf)) != sizeof(elf))
     goto bad;
   if(elf.magic != ELF_MAGIC)
     goto bad;