From a9ba821609b11eb2f679d6257c3b897c65ac0abe Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 17 Apr 2012 09:55:50 +0200 Subject: 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 --- common/filetype.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common/filetype.c') 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); -- cgit v1.2.3