[PATCH 9/9] Die on early EOF in slurp_file, instead of infinite-looping.

Jamey Sharp jamey at thetovacompany.com
Tue Apr 22 19:21:12 EDT 2008


Signed-off-by: Jamey Sharp <jamey at thetovacompany.com>
---
A "shouldn't happen" case that I triggered due to a different bug in
Windows. I thought that, in the unlikely event that this case occurs, an
infinite loop is a rather harsh result.

 kexec/kexec.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/kexec/kexec.c b/kexec/kexec.c
index 3a1656a..f898428 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -408,6 +408,8 @@ char *slurp_file(const char *filename, off_t *r_size)
 			die("read on %s of %ld bytes failed: %s\n", filename,
 			    (size - progress)+ 0UL, strerror(errno));
 		}
+		if (result == 0)
+			die("read on %s ended before stat said it should\n", filename);
 		progress += result;
 	}
 	result = close(fd);
-- 
1.5.4.1




More information about the kexec mailing list