[alsa-devel] Bug in ALSA-utils/arecord with --max-file-time

Gilliland, Scott M scott.gilliland at gatech.edu
Fri Jun 23 17:18:58 CEST 2017


How does this look? 
-- 
Scott Gilliland
imtc.gatech.edu/people/scott-gilliland
    
From: Takashi Iwai <tiwai at suse.de>
Sent: Friday, June 23, 2017 10:02:18 AM
To: Gilliland, Scott M
Cc: alsa-devel at alsa-project.org
Subject: Re: [alsa-devel] Bug in ALSA-utils/arecord with --max-file-time
    
On Fri, 23 Jun 2017 00:08:58 +0200,
Gilliland, Scott M wrote:
> 
> Hi All,
> 
> I seem to have found a minor bug in aplay, within alsa-utils 1.1.4. It's possible that I'm the first person who's ever hit it. This appears to be the correct place to report it; if not, I humbly apologize, and ask for direction on where to submit this.
> 
> In aplay.c, around line 3030, we do this calculation:
> 
>         max_file_size = max_file_time *
>                 snd_pcm_format_size(hwparams.format,
>                                     hwparams.rate * hwparams.channels);
> 
> We do this to convert max_file_time from the '--max-file-time' parameter (an int) into max_file_size, a file length in bytes (a long long). Since snd_pcm_format_size() may return something 32-bit, this might overflow 32-bits when we do the multiplication,  wasting the extra bytes of max_file_size. 
> 
> On my test case on an armv7l system, a 1800-second file at 192 KHz recorded in S24_3LE doesn't overflow, but recording in S32_LE does. I accidentally found an edge case.  In case anyone wants to know, the failure mode is that arecord will repeatedly create  44 byte .wav files very quickly, since these are larger than the negative max file size. This continues until you have a directory full of thousands of 44-byte files. Hilarious.
> 
> A simple change to cast max_file_time to a long long fixes this in my test case. There might be some cleaner solution, but this at least worked for me.
> 
>         max_file_size = (long long) max_file_time *
>                 snd_pcm_format_size(hwparams.format,
>                                     hwparams.rate * hwparams.channels);
> 
> Hopefully someone can vet this and carry it over to git. I've attached a patch file as well.

The change looks good.  Could you post as a proper patch, i.e. with a
commit log and your sign-off?


> Additionally, while working to report this, I noticed that the bug tracker link on the sidebar of https://www.alsa-project.org/main/index.php/Main_Page is a dead link.

Yeah, it's a known problem for long time...


Takashi
    
-------------- next part --------------
A non-text attachment was scrubbed...
Name: max-size-cast.patch
Type: text/x-patch
Size: 735 bytes
Desc: max-size-cast.patch
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20170623/aeb926b3/attachment-0001.bin>


More information about the Alsa-devel mailing list