Subject: pkg/8610: pkgsrc/audio/lame exits normally on input file read error
To: None <gnats-bugs@gnats.netbsd.org>
From: Sean Doran <smd@ebone.net>
List: netbsd-bugs
Date: 10/11/1999 15:54:52
>Number: 8610
>Category: pkg
>Synopsis: lame has bad read error handling in read_samples() [getaudio.c:431]
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: pkg-manager (NetBSD software packages system bug manager)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Oct 11 15:03:00 1999
>Last-Modified:
>Originator: Sean Doran
>Organization:
>Release: 19991009
>Environment:
System: NetBSD crasse.smd.ebone.net 1.4K NetBSD 1.4K (SMDHOME) #0: Sat Oct 9 16:37:47 CEST 1999 smd@crasse.smd.ebone.net:/usr/src/sys/arch/i386/compile/SMDHOME i386
pkgsrc supped 9 Oct 1999
>Description:
pkg/lame (and pkg/lame-gui) suffers from poor read error
handling in read_samples() [getaudio.c:431]
in particular, when fread(3) returns 0, there is no attempt
to determine why; the code just falls through a commented-out
printf (!)
moreover, a short fread(3) [including a 0 "short read"]
returns upwards towards a comment in makeframe() [main.c:11]
/* even if iread=0, get_audio hit EOF and returned Buffer=all 0's. call
* makeframe() one last time to flush all buffers */
gross! we might not have hit EOF! we should NOT NOT NOT exit
normally!
lame_lastreadframe() [musicin.c:1315] is funny.
static int eof;
...
if(!eof) {
if( (###result of fread from read_samples ###) == 0 ) {
/*this is the last frame*/
..
eof=1;
} else {
/*do cleanup*/
}
>How-To-Repeat:
1 Use pkgsrc/audio/cdd to dump a bunch of PCM files onto a partition
on a flaking-out disk (unrecoverable reads)
2 run a simple script like this one in pkgsrc/plan9/rc dialect:
#!/bin/rc
lameopts=(--nohist -m f -p -h -v -V 5 -b 32 -x -r)
for (a in $*) {
b=`{echo $a | sed 's,.cda$,.mp3,'}
echo $^a '->' $^b
/usr/pkg/bin/lame $lameopts $^a $^b && /bin/rm -f $^a
}
3 become REALLY annoyed when you discover that lame exits normally
when a read error happens
Alternatively:
$ /bin/rc
: crasse ; lameopts=(--nohist -m f -p -h -v -V 5 -b 32 -x -r)
: crasse ; cat /etc/rc.local | lame $lameopts - /tmp/x
: crasse ; echo $status
0 0
: crasse ; lame $lameopts /tmp/doesnotexist /tmp/x
LAME version 3.31 (www.sulaco.org/mp3)
GPSYCHO: GPL psycho-acoustic model version 0.73.
Could not find "/tmp/doesnotexist".
: crasse ; echo $status
1
: crasse ; cat /tmp/doesnotexist | lame $lameopts - /tmp/xxx
cat: /tmp/doesnotexist: No such file or directory
LAME version 3.31 (www.sulaco.org/mp3)
GPSYCHO: GPL psycho-acoustic model version 0.73.
Assuming raw pcm input file : Forcing byte-swapping
Encoding stdin to /tmp/xxx
Encoding as 44.1kHz VBR(q=5) j-stereo MPEG1 LayerIII file
: crasse ; echo $status
1 0
At least cat(1) exits with nonzero status... ^*&@#$
>Fix:
>Audit-Trail:
>Unformatted: