Bug 127658

Summary: xcdroast segfaults parsing cdda2wav output
Product: [Fedora] Fedora Reporter: Tim Waugh <twaugh>
Component: xcdroastAssignee: Harald Hoyer <harald>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 2   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-07-13 13:52:08 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
xcdroast-linebuffer.patch none

Description Tim Waugh 2004-07-12 10:03:57 UTC
Description of problem:
Due to the way that xcdroast parses output from cdda2wav, it may
segfault while reading the table of contents of a CD.

Version-Release number of selected component (if applicable):
xcdroast-0.98a15-2
cdda2wav-2.01-0.a27.4.FC2.1

How reproducible:
From time to time in normal usage.  Can be forced.

The problem is that xcdroast expects to read() entire lines from
cdda2wav's output file descriptor, but that isn't how it write()s:

write(2, "T22:", 4)                     = 4
write(2, "  340375", 8)                 = 8
write(2, "  3:01.32", 9)                = 9
write(2, " audio pre-emphasized copydenied stereo", 39) = 39

So there is a race condition where cdda2wav may have started writing a
line but not finished, and xcdroast has begun to parse it.

(gdb) bt
#0  0x08089d36 in parse_toc_line (line=0xfee5ab00 "T22:  340375  3:01.32")
    at io.c:2686
#1  0x0808a880 in parse_toc (line=0xfee5ab00 "T22:  340375  3:01.32")
    at io.c:2930
#2  0x0808aa0f in getcdtoc_out (data=0x0, source=135150288,
    cond=GDK_INPUT_READ) at io.c:2979
#3  0x0013bb3b in gdk_get_show_events () from /usr/lib/libgdk-x11-2.0.so.0
#4  0x00000000 in ?? ()

Here, xcdroast requires 'data' or 'audio' following the track length,
but cdda2wav didn't write that out before xcdroast read the line.

Comment 1 Tim Waugh 2004-07-12 11:30:36 UTC
Created attachment 101806 [details]
xcdroast-linebuffer.patch

This patch works around the problem for me.