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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux