Subject: bin/8748: audioplay exits on empty string arguments ""
To: None <gnats-bugs@gnats.netbsd.org>
From: Ben Wong <hackerb9@ursula.wongs.net>
List: netbsd-bugs
Date: 11/04/1999 20:12:45
>Number:         8748
>Category:       bin
>Synopsis:       audioplay exits on empty string arguments ""
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Nov  4 20:12:00 1999
>Last-Modified:
>Originator:     Ben Wong
>Organization:
>Release:        1.4.1
>Environment:
	
System: NetBSD ursula.wongs.net 1.4.1 NetBSD 1.4.1 (AMNESIAC) #7: Thu Oct 14 22:00:19 EDT 1999 hackerb9@ursula.wongs.net:/usr/src/sys/arch/i386/compile/AMNESIAC i386


>Description:

When audioplay is passed an argument which is the empty string, it
tries to open that as the name of a file to play. It dies with an
error message instead of continuing on to see if there are any valid
files to play in argv. This is a problem because some playlist
managers (such as xhippo) might send in the empty string in the middle
of the arg list.

Ideally audioplay should both (a) be silent about the empty string is
passed in and (b) continue playing other files that may have been
listed even if a previous one caused an error.

>How-To-Repeat:

Assuming you have an audiofile in your cwd called "somefile.wav"

	audioplay "" somefile.wav

audioplay will never play somefile.wav

>Fix:

Make audioplay check if the argument string is empty and silently go
on to the next argument. Also, someone should probably change many of
the calls to err() with warnx() since it shouldn't be fatal if one out
of many files is missing or of an unknown format.

Here is a patch for /usr/src/usr.bin/audio/play/play.c to make
audioplay work with xhippo:

*** play.c~     Thu Nov  4 22:55:30 1999
--- play.c      Thu Nov  4 22:56:25 1999
***************
*** 185,190 ****
--- 185,193 ----
                void *addr, *oaddr;
  
                do {
+                       if (strlen(*argv) == 0)
+                         continue;
+ 
                        fd = open(*argv, O_RDONLY);
                        if (fd < 0)
                                err(1, "could not open %s", *argv);
>Audit-Trail:
>Unformatted: