gpm 1.20.0 - bug in vc number detection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[note: I am not subscriber of gpm list, so please Cc: to me when you answer]

Hello,

I've just found a bug in vc detection in Gpm_Open().

In Gpm_Open() (liblow.c) there is:

         if(strncmp(tty,consolename,strlen(consolename)-1)
            || !isdigit(tty[strlen(consolename)-1])) {
            gpm_report(GPM_PR_ERR,"strncmp/isdigit/consolename failed");
            goto err;
         }

         conn->vc=atoi(&tty[strlen(consolename)]);

Note that consolename[strlen(consolename)] points at char just _after_ 0
in "/dev/tty0" or "/dev/vc/0" string. So tty[strlen(consolename)] points
to \0 if console number fits in one digit, or to second digit of console
number (the first is more common). In the first situation vc==0, so gpm
tries to open /dev/tty0, which can fail if current user doesn't own it.

Fix is simple:

--- gpm-1.20.0/src/liblow.c.orig	Sat Feb 23 16:42:23 2002
+++ gpm-1.20.0/src/liblow.c	Wed May 15 22:08:34 2002
@@ -262,7 +262,7 @@
             goto err;
          }   
           
-         conn->vc=atoi(&tty[strlen(consolename)]);
+         conn->vc=atoi(&tty[strlen(consolename)-1]);
       }
 
       if (gpm_consolefd == -1)


-- 
Jakub Bogusz    http://prioris.mini.pw.edu.pl/~qboosh/
PLD Linux       http://www.pld.org.pl/


[Index of Archives]     [Kernel Development]     [Red Hat Install]     [Red Hat Watch]     [Red Hat Development]     [Gimp]     [Yosemite News]