mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] filetype: Make it work on files < 512 bytes
@ 2012-04-17  7:57 Sascha Hauer
  0 siblings, 0 replies; only message in thread
From: Sascha Hauer @ 2012-04-17  7:57 UTC (permalink / raw)
  To: barebox

This is a brown paper bag type of bugs. Do not assume that a file
has to be at minimun 512 bytes to be detectable.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/filetype.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/filetype.c b/common/filetype.c
index 4b5a6fa..15a3732 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -92,10 +92,10 @@ enum filetype file_name_detect_type(const char *filename)
 	if (fd < 0)
 		return fd;
 
-	buf = xmalloc(512);
+	buf = xzalloc(512);
 
 	ret = read(fd, buf, 512);
-	if (ret != 512)
+	if (ret < 0)
 		goto err_out;
 
 	type = file_detect_type(buf);
-- 
1.7.10


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-04-17  7:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-17  7:57 [PATCH] filetype: Make it work on files < 512 bytes Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox