]> git.alsa-project.org Git - alsa-utils.git/commitdiff
aplay: Fix invalid file size check for non-regular files
authorTakashi Iwai <tiwai@suse.de>
Tue, 15 May 2018 20:17:01 +0000 (22:17 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 15 May 2018 20:17:01 +0000 (22:17 +0200)
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>
aplay/aplay.c

index bbd7fffa04fc3be6afc0449d1e378ce70c38041f..63ec9efbebc1b141df3f701715e223ab3b1b6e5b 100644 (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) {