From 79d43675f4fd36237529d676e3c7c231b308dc7f Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 8 Apr 2006 18:34:47 +0000 Subject: [PATCH] Don't read anything from the disk for a segment with p_filesz == 0. Thanks to Godmar Back for reporting this bug. --- src/userprog/process.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) { -- 2.30.2