Subject: xsrc/13695: XFree86 DGA extension is not functional on i386.
To: None <gnats-bugs@gnats.netbsd.org>
From: None <svs@ropnet.ru>
List: netbsd-bugs
Date: 08/12/2001 13:27:30
>Number:         13695
>Category:       xsrc
>Synopsis:       XFree86 DGA extension is not functional on i386.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    xsrc-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Aug 12 13:24:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Sergey Svishchev
>Release:        1.5X
>Organization:
>Environment:

>Description:
Kernel is compiled with "options INSECURE", aperture driver is not loaded.

XFree86 3.3.6 is used (XFree 4 does not support desired display depth
on my card.)

Application (MPlayer) calls XF86DGAGetVideo and this call
fails with EINVAL because signed variable was sign-extended (by cast to
off_t), making it negative (analysis was done by Chuck Silvers in
http://mail-index.netbsd.org/tech-kern/2001/05/27/0001.html.)

>How-To-Repeat:
Build MPlayer, try to use DGA video output (-vo dga), lose.

>Fix:
--- xsrc/xc/include/extensions/xf86dga.h.orig	Tue Jul 20 21:42:17 1999
+++ xsrc/xc/include/extensions/xf86dga.h	Sat Jun 30 18:57:23 2001
@@ -65,7 +65,7 @@
 #if NeedFunctionPrototypes
     Display*			/* dpy */,
     int				/* screen */,
-    int *			/* base addr */,
+    off_t *			/* base addr */,
     int *			/* width */,
     int *			/* bank_size */,
     int *			/* ram_size */ 
--- xsrc/xc/lib/Xxf86dga/XF86DGA.c.orig	Wed Sep  1 22:46:32 1999
+++ xsrc/xc/lib/Xxf86dga/XF86DGA.c	Sat Jun 30 18:57:47 2001
@@ -114,7 +114,7 @@
 Bool XF86DGAGetVideoLL(dpy, screen, offset, width, bank_size, ram_size)
     Display* dpy;
     int screen;
-    int *offset;
+    off_t *offset;
     int *width, *bank_size, *ram_size;
 {
     XExtDisplayInfo *info = find_display (dpy);
@@ -135,7 +135,7 @@
 	return False;
     }
 
-    *offset = /*(char *)*/rep.offset;
+    *offset = (off_t) rep.offset;
     *width = rep.width;
     *bank_size = rep.bank_size;
     *ram_size = rep.ram_size;
@@ -564,7 +564,8 @@
 char **addr;
 int *width, *bank, *ram;
 {
-   int offset, fd;
+   int fd;
+   off_t offset;
 #ifdef __EMX__
    APIRET rc;
    ULONG action;
@@ -689,10 +690,10 @@
    /* This requires linux-0.99.pl10 or above */
    *addr = (void *)mmap(NULL, *bank, PROT_READ,
                         MAP_FILE | MAP_SHARED, fd, 
-			(off_t)offset + bus_base_addr);
+			offset + bus_base_addr);
 #ifdef DEBUG
    fprintf(stderr, "XF86DGAGetVideo: physaddr: 0x%08x, size: %d\n",
-	   (long)offset, *bank);
+	   (unsigned long)offset, *bank);
 #endif
    if (*addr == (char *) -1) {
         fprintf(stderr, "XF86DGAGetVideo: failed to mmap %s (%s)\n",

>Release-Note:
>Audit-Trail:
>Unformatted: