diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2012-04-17 09:55:50 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-04-17 21:31:47 +0200 |
commit | a9ba821609b11eb2f679d6257c3b897c65ac0abe (patch) | |
tree | b7c71c3218949b434b0ec972837f1f7198201ecf /common/filetype.c | |
parent | 6a0ab1d78769ec20fc69da02362c5ce5b76e1a82 (diff) | |
download | barebox-a9ba821609b11eb2f679d6257c3b897c65ac0abe.tar.gz barebox-a9ba821609b11eb2f679d6257c3b897c65ac0abe.tar.xz |
filetype: Make it work on files < 512 bytes
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>
Diffstat (limited to 'common/filetype.c')
-rw-r--r-- | common/filetype.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/common/filetype.c b/common/filetype.c index 40faff3ada..f662258db7 100644 --- a/common/filetype.c +++ b/common/filetype.c @@ -86,10 +86,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); |