Date: Thu, 4 May 1995 18:40:02 -0700 From: Paul Traina <pst@Shockwave.COM> To: freebsd-bugs Subject: kern/382: divide by zero in speaker driver Message-ID: <199505050140.SAA07323@freefall.cdrom.com> In-Reply-To: Your message of Thu, 4 May 1995 18:33:55 -0700 <199505050133.SAA00402@precipice.shockwave.com>
index | next in thread | previous in thread | raw e-mail
>Number: 382
>Category: kern
>Synopsis: kernel divide by zero in spkr driver code
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs (FreeBSD bugs mailing list)
>State: open
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Thu May 4 18:40:01 1995
>Originator: Peter Shipley / Paul Traina
>Organization:
>Release: FreeBSD 2.1.0-Development i386
>Environment:
FreeBSD 1.1 through FreeBSD-current.
>Description:
The speaker code has some divides in it that are not protected.
>How-To-Repeat:
echo n90 >/dev/speaker
>Fix:
*** spkr.c Thu Mar 16 13:16:46 1995
--- spkr.c Thu May 4 18:24:55 1995
***************
*** 66,74 ****
/* emit tone of frequency thz for given number of ticks */
unsigned int thz, ticks;
{
! unsigned int divisor = TIMER_CLK / thz;
int sps;
#ifdef DEBUG
(void) printf("tone: thz=%d ticks=%d\n", thz, ticks);
#endif /* DEBUG */
--- 66,79 ----
/* emit tone of frequency thz for given number of ticks */
unsigned int thz, ticks;
{
! unsigned int divisor;
int sps;
+ if (thz <= 0)
+ return;
+
+ divisor = TIMER_CLK / thz;
+
#ifdef DEBUG
(void) printf("tone: thz=%d ticks=%d\n", thz, ticks);
#endif /* DEBUG */
***************
*** 205,210 ****
--- 210,218 ----
rest(whole * snum / (value * sdenom));
else
{
+ if (value == 0 || sdenom == 0)
+ return;
+
sound = (whole * snum) / (value * sdenom)
- (whole * (FILLTIME - fill)) / (value * FILLTIME);
silence = whole * (FILLTIME-fill) * snum / (FILLTIME * value * sdenom);
>Audit-Trail:
>Unformatted:
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199505050140.SAA07323>
