Patch to fix minor mistakes in Gpm_Open

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

 



Less verbage and more code:

gpm06122002-cvs-tty.patch applies against the cvs repository
gpm-1.20.0-tty.patch applies against the current release

This patch fixes some off by one bugs which were introduced
into the Gpm_Open function of liblow.c when devfs support was added.

The patches are simple, please apply if you find them to be correct.

Thanks,
Scott


Kerry Scott McLeod
Georgia Institute of Technology, Atlanta Georgia, 30332
uucp:	  ...!{decvax,hplabs,ncar,purdue,rutgers}!gatech!prism!gt2921b
Internet: gt2921b@xxxxxxxxxxxxxxxx
diff -urN ./gpm.cvs.orig/src/liblow.c ./gpm/src/liblow.c
--- ./gpm.cvs.orig/src/liblow.c	2002-05-28 15:13:58.000000000 -0400
+++ ./gpm/src/liblow.c	2002-06-13 16:28:45.000000000 -0400
@@ -243,9 +243,9 @@
       conn->vc=0;                 /* default handler */
       if (flag > 0) {  /* forced vc number */
          conn->vc=flag;
-         if((tty = malloc(strlen(consolename)+Gpm_cnt_digits(flag))) != NULL)
+         if((tty = malloc(strlen(consolename)+Gpm_cnt_digits(flag))) == NULL)
             gpm_report(GPM_PR_OOPS,GPM_MESS_NO_MEM);
-         snprintf(tty,strlen(consolename)-1,"%s",consolename);
+         memcpy(tty,consolename,strlen(consolename)-1);
          sprintf(&tty[strlen(consolename)-1],"%i",flag);
       } else { /* use your current vc */ 
          if (isatty(0)) tty = ttyname(0);             /* stdin */
@@ -262,7 +262,7 @@
             goto err;
          }
           
-         conn->vc=atoi(&tty[strlen(consolename)]);
+         conn->vc=atoi(&tty[strlen(consolename)-1]);
       }
 
       if (gpm_consolefd == -1)
diff -urN gpm-1.20.0.orig/src/liblow.c gpm-1.20.0/src/liblow.c
--- gpm-1.20.0.orig/src/liblow.c	2002-02-23 10:42:23.000000000 -0500
+++ gpm-1.20.0/src/liblow.c	2002-06-13 16:44:51.000000000 -0400
@@ -243,9 +243,9 @@
       conn->vc=0;                 /* default handler */
       if (flag > 0) {  /* forced vc number */
          conn->vc=flag;
-         if((tty = malloc(strlen(consolename)+Gpm_cnt_digits(flag))) != NULL)
+         if((tty = malloc(strlen(consolename)+Gpm_cnt_digits(flag))) == NULL)
             gpm_report(GPM_PR_OOPS,GPM_MESS_NO_MEM);
-         snprintf(tty,strlen(consolename)-1,"%s",consolename);
+         memcpy(tty,consolename,strlen(consolename)-1);
          sprintf(&tty[strlen(consolename)-1],"%i",flag);
       } else { /* use your current vc */ 
          if (isatty(0)) tty = ttyname(0);             /* stdin */
@@ -262,7 +262,7 @@
             goto err;
          }   
           
-         conn->vc=atoi(&tty[strlen(consolename)]);
+         conn->vc=atoi(&tty[strlen(consolename)-1]);
       }
 
       if (gpm_consolefd == -1)

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