From: Takashi Iwai Date: Tue, 15 May 2018 20:17:01 +0000 (+0200) Subject: aplay: Fix invalid file size check for non-regular files X-Git-Tag: v1.1.7~20 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=da4d5bd53a1a57d1b39318b83d3280fbcd78e9f6;p=alsa-utils.git 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 Signed-off-by: Takashi Iwai --- diff --git a/aplay/aplay.c b/aplay/aplay.c index bbd7fff..63ec9ef 100644 --- a/aplay/aplay.c +++ b/aplay/aplay.c @@ -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) {