aplay: Fix invalid file size check for non-regular files

aplay tries to check the file size via fstat() at parsing the format
headers and avoids parsing when the size is shorter than the given
size.  This works fine for regular files, but when a special file like
pipe is passed, it fails, eventually leading to the fallback mode
wrongly.

A proper fix is to do this sanity check only for a regular file.

Reported-by: Jay Foster <jay@systech.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Iwai 2018-05-15 22:17:01 +02:00
parent 9a6ab34203
commit da4d5bd53a

View file

@ -2821,7 +2821,8 @@ static int read_header(int *loaded, int header_size)
/* don't be adventurous, get out if file size is smaller than
* requested header size */
if (buf.st_size < header_size)
if ((buf.st_mode & S_IFMT) == S_IFREG &&
buf.st_size < header_size)
return -1;
if (*loaded < header_size) {