From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH] filetype: Make it work on files < 512 bytes
Date: Tue, 17 Apr 2012 09:57:42 +0200 [thread overview]
Message-ID: <1334649462-24971-1-git-send-email-s.hauer@pengutronix.de> (raw)
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
reply other threads:[~2012-04-17 7:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1334649462-24971-1-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox