Don't read anything from the disk for a segment with p_filesz == 0.
authorBen Pfaff <blp@cs.stanford.edu>
Sat, 8 Apr 2006 18:34:47 +0000 (18:34 +0000)
committerBen Pfaff <blp@cs.stanford.edu>
Sat, 8 Apr 2006 18:34:47 +0000 (18:34 +0000)
Thanks to Godmar Back for reporting this bug.

src/userprog/process.c

index a81ca590fea187321197c699950df0e38cdbc40f..8c410aba98519a273d5d7a60155468f5b4ffc556 100644 (file)
@@ -333,7 +333,9 @@ load_segment (struct file *file, const struct Elf32_Phdr *phdr)
     return false; 
 
   /* Load the segment page-by-page into memory. */
-  filesz_left = phdr->p_filesz + (phdr->p_vaddr & PGMASK);
+  filesz_left = phdr->p_filesz;
+  if (filesz_left > 0)
+    filesz_left += phdr->p_vaddr & PGMASK;
   file_seek (file, ROUND_DOWN (phdr->p_offset, PGSIZE));
   for (upage = start; upage < (uint8_t *) end; upage += PGSIZE) 
     {