From pa4dan@vitsch.net  Sun Apr 20 07:48:34 2003
Return-Path: <pa4dan@vitsch.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 3288837B401
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 20 Apr 2003 07:48:34 -0700 (PDT)
Received: from Vitsch.net (b83007.upc-b.chello.nl [212.83.83.7])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 76DF343FAF
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 20 Apr 2003 07:48:32 -0700 (PDT)
	(envelope-from pa4dan@vitsch.net)
Received: from vitsch.net (localhost [127.0.0.1])
	by FreeBSD.Danovitsch.LAN (8.12.6/8.12.6) with ESMTP id h3GHpdh7002060;
	Wed, 16 Apr 2003 19:51:39 +0200 (CEST)
	(envelope-from pa4dan@vitsch.net)
Received: (from pa4dan@localhost)
	by vitsch.net (8.12.6/8.12.6/Submit) id h3GHpcw6002059;
	Wed, 16 Apr 2003 19:51:38 +0200 (CEST)
Message-Id: <200304161751.h3GHpcw6002059@vitsch.net>
Date: Wed, 16 Apr 2003 19:51:38 +0200 (CEST)
From: "Daan Vreeken [PA4DAN]" <pa4dan@vitsch.net>
Reply-To: "Daan Vreeken [PA4DAN]" <pa4dan@vitsch.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc: Danovitsch@vitsch.net
Subject: pointer arithmatic error in ugen.c
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         51186
>Category:       kern
>Synopsis:       pointer arithmatic error in ugen.c
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    jmg
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Apr 20 07:50:14 PDT 2003
>Closed-Date:    Tue Jul 20 19:37:37 GMT 2004
>Last-Modified:  Tue Jul 20 19:37:37 GMT 2004
>Originator:     Daan Vreeken [PA4DAN]
>Release:        FreeBSD 5.0
>Organization:
none
>Environment:
System: FreeBSD 5.0 (and all others I checked)


>Description:

I believe there is a pointer arithmatic error in line 965 of ugen.c .
The entire piece of code reads :

961:    /* throw away oldest input if the buffer is full */
962:    if(sce->fill < sce->cur && sce->cur <= sce->fill + count) {
963:            sce->cur += count;
964:            if(sce->cur >= sce->limit)
965:                    sce->cur = sce->ibuf + (sce->limit - sce->cur);
966:            DPRINTFN(5, ("ugen_isoc_rintr: throwing away %d bytes\n",
967:                        count));
978:    }

count gets added to sce->cur .
if the pointer equals/exceeds the end of the buffer, we move it to the
beginnen of the buffer (plus the X bytes it was past the end).

If sce->cur exceeds sce->limit, (sce->cur - sce->limit) would be a negative
value. (resulting in a sce->cur pointer sitting X bytes before the beginning
of the buffer)


>How-To-Repeat:
	n/a

>Fix:

--- ugen.c.diff begins here ---
965c965
< 			sce->cur = sce->ibuf + (sce->limit - sce->cur);
---
> 			sce->cur = sce->ibuf + (sce->cur - sce->limit);
--- ugen.c.diff ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->imp 
Responsible-Changed-By: imp 
Responsible-Changed-When: Tue Jul 22 12:58:22 MDT 2003 
Responsible-Changed-Why:  
I'll integrate this. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=51186 
Responsible-Changed-From-To: imp->jmg 
Responsible-Changed-By: jmg 
Responsible-Changed-When: Tue Dec 9 16:02:10 PST 2003 
Responsible-Changed-Why:  
I'll nab this from you. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=51186 
State-Changed-From-To: open->closed 
State-Changed-By: le 
State-Changed-When: Tue Jul 20 19:37:05 GMT 2004 
State-Changed-Why:  
Patch committed to ugen.c rev. 1.86 by imp@. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=51186 
>Unformatted:
