9
0
Fork 0

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>
This commit is contained in:
Sascha Hauer 2012-04-17 09:55:50 +02:00
parent 6a0ab1d787
commit a9ba821609
1 changed files with 2 additions and 2 deletions

View File

@ -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);