From owner-freebsd-ports Sun Nov 22 12:09:58 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id MAA08039 for freebsd-ports-outgoing; Sun, 22 Nov 1998 12:09:58 -0800 (PST) (envelope-from owner-freebsd-ports@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id MAA08031 for ; Sun, 22 Nov 1998 12:09:56 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id MAA23245; Sun, 22 Nov 1998 12:10:01 -0800 (PST) Received: from localhost.ziplink.net (kot.ne.mediaone.net [24.128.29.55]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id MAA07793 for ; Sun, 22 Nov 1998 12:05:32 -0800 (PST) (envelope-from mi@aldan.ziplink.net) Received: from rtfm.ziplink.net (mi@rtfm [199.232.255.52]) by localhost.ziplink.net (8.9.1a/8.9.1) with ESMTP id UAA04471 for ; Sun, 22 Nov 1998 20:04:16 GMT Received: (from mi@localhost) by rtfm.ziplink.net (8.9.1/8.9.1) id PAA17112; Sun, 22 Nov 1998 15:05:07 -0500 (EST) Message-Id: <199811222005.PAA17112@rtfm.ziplink.net> Date: Sun, 22 Nov 1998 15:05:07 -0500 (EST) From: Mikhail Teterin Reply-To: mi@aldan.algebra.com To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: ports/8795: xgalaga's sound driver Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 8795 >Category: ports >Synopsis: xgal.sndsrv.freebsd.c is out of sync with sound.h >Confidential: no >Severity: critical >Priority: medium >Responsible: freebsd-ports >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Nov 22 12:10:01 PST 1998 >Last-Modified: >Originator: Mikhail Teterin >Organization: Virtual Estates, Inc. >Release: FreeBSD 3.0-CURRENT i386 >Environment: >Description: Currently, the xgal.sndsrv.freebsd.c, which lists 6 sound files is out of sync with the game's sound.h, which expects 8 different sounds. My version of the port's patch-ab adds the two more files (in the correct order) and puts a simple bounds checking in place, so that the next time this things get out of date, the xgal.sndsrv.freebsd will spit a reasonable complaint out, isntead of crashing and/or complaining about the absence of "(null)" sound. >How-To-Repeat: Play xgalaga with sound, manage to get through the first level. When xgalaga switches you to the second level, the sound server will either die, killing the whole game, or spit a misleading error message. >Fix: Put the following instead of the patches/patch-ab and remove the mentioning of core dumps in pkg/DESCR --- xgal.sndsrv.freebsd.c.orig Sun Apr 12 02:03:21 1998 +++ xgal.sndsrv.freebsd.c Sun Nov 22 15:01:01 1998 @@ -20,5 +20,5 @@ -char *FILENAME[] = { +static const char *FILENAME[] = { "/explode.raw", "/firetorp.raw", @@ -27,4 +27,8 @@ "/explode_big.raw", "/ddloo.raw", +/* Two more files are now expected by the xgalaga! +\* The order is given in the sound.h -mi */ + "/warp.raw", + "/smart.raw" }; @@ -37,15 +41,13 @@ /* Terminate: Signal Handler */ -void quit () +static void quit () { exit (0); } - - -void init (int argc, char **argv) +static void init (int argc, char **argv) { int i; - char s[1024]; + char s[FILENAME_MAX]; if (argc != 3) @@ -62,5 +64,5 @@ strcat (s, FILENAME[i]); FILENAME[i] = malloc ((int)strlen (s)); - strcpy (FILENAME[i],s); + strcpy ((char *)FILENAME[i],s); sound_buffer[i]=NULL; sound_size[i]=0; @@ -78,10 +80,10 @@ Error checking */ -int setup_dsp (char *dspdev,int *is_pcsp) +static int setup_dsp (char *dspdev,int *is_pcsp) { int dsp, frag, value; int mixer; - dsp = open(dspdev, O_RDWR); + dsp = open(dspdev, O_WRONLY); if (dsp < 1) { @@ -134,5 +136,5 @@ just trap this. */ -int do_nothing(void) +static int do_nothing(void) { fprintf(stderr,"xgal.sndsrv: doing nothing, something is broken\n"); @@ -140,5 +142,5 @@ } -int read_sound(int k) +static int read_sound(int k) { int i,fd,size; @@ -174,5 +176,5 @@ -void do_everything (int dsp, int is_pcsp) +static void do_everything (int dsp, int is_pcsp) { char k; @@ -201,6 +203,12 @@ terminate = 0; } else { - if(sound_size[k]==0) read_sound(k); - if(sound_size[k]>0 && playnum<16) { + if(k>=NUM_SOUNDS) { + fprintf(stderr, + "Not that many sounds known (%d >= %d)\n", + (int)k, NUM_SOUNDS); + continue; + }; + if(sound_size[(int)k]==0) read_sound((int)k); + if(sound_size[(int)k]>0 && playnum<16) { position[playnum]=0; playing[playnum++]=k; @@ -252,12 +260,9 @@ } - - -void main (argc, argv) +int main (argc, argv) int argc; char **argv; { - int dsp, is_pcsp, ppid; - char filename[512]; + int dsp, is_pcsp; fcntl(STDIN_FILENO,F_SETFL,O_NONBLOCK); @@ -268,3 +273,4 @@ do_everything (dsp, is_pcsp); + return 0; } >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message