Subject: bin/18902: audioplay accesses audiofd after closing it
To: None <gnats-bugs@gnats.netbsd.org>
From: Christian Biere <christianbiere@gmx.de>
List: netbsd-bugs
Date: 11/03/2002 20:22:04
>Number:         18902
>Category:       bin
>Synopsis:       audioplay accesses audiofd after closing it
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Nov 03 11:23:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Christian Biere
>Release:        NetBSD 1.6J
>Organization:
       
>Environment:
NetBSD localhost 1.6J NetBSD 1.6J (UNICRON) #5: Mon Oct 28 17:05:26 CET
2002     root@localhost:/usr/src/sys/arch/i386/compile/UNICRON i386

>Description:
See the patch. It's obvious.

>How-To-Repeat:
ktruss audioplay -f /dev/null

That's (nearly) how I tripped over this.

>Fix:

--Multipart_Sun__3_Nov_2002_20:22:04_+0100_081fe000
Content-Type: text/plain;
 name="play.c.udif"
Content-Disposition: attachment;
 filename="play.c.udif"
Content-Transfer-Encoding: 7bit

Index: play.c
===================================================================
RCS file: /cvsroot/basesrc/usr.bin/audio/play/play.c,v
retrieving revision 1.38
diff -u -r1.38 play.c
--- play.c	2002/10/01 20:22:10	1.38
+++ play.c	2002/11/03 18:59:08
@@ -197,10 +197,9 @@
 cleanup(signo)
 	int signo;
 {
-
-	close(audiofd);
 	(void)ioctl(audiofd, AUDIO_FLUSH, NULL);
 	(void)ioctl(audiofd, AUDIO_SETINFO, &info);
+	close(audiofd);
 	exit(exitstatus);
 }
 
@@ -291,7 +290,7 @@
 }
 
 /*
- * play the file on on the file descriptor fd
+ * play the file on the file descriptor fd
  */
 void
 play_fd(file, fd)

--Multipart_Sun__3_Nov_2002_20:22:04_+0100_081fe000--
>Release-Note:
>Audit-Trail:
>Unformatted:
 This is a multi-part message in MIME format.
 
 --Multipart_Sun__3_Nov_2002_20:22:04_+0100_081fe000
 Content-Type: text/plain; charset=US-ASCII
 Content-Transfer-Encoding: 7bit