From: Ben Pfaff Date: Sat, 8 Apr 2006 18:34:47 +0000 (+0000) Subject: Don't read anything from the disk for a segment with p_filesz == 0. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=68d3a93433f506864f6c6cec8af0f5f4538a4a40;p=pintos-anon Don't read anything from the disk for a segment with p_filesz == 0. Thanks to Godmar Back for reporting this bug. --- diff --git a/src/userprog/process.c b/src/userprog/process.c index a81ca59..8c410ab 100644 --- a/src/userprog/process.c +++ b/src/userprog/process.c @@ -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) {