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:
parent
6a0ab1d787
commit
a9ba821609
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue