gpm 1.19.4 - SEGV in Gpm_Open()
Jakub Bogusz
qboosh@pld.org.pl
Sat, 8 Sep 2001 17:18:01 +0200
--y0ulUmNC+osPPQO6
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
[note: I am not subscriber of gpm list, so please Cc: to me when you answer]
There is a bug in libgpm (1.19.4), which causes segmentation fault in
programs that use libgpm (e.g. mc, links).
Bug is in devfs support in Gpm_Open() function (liblow.c file).
Local variable (devfs_id) is used without initializing.
I attach a patch with fix for this bug.
Note that check_devfs() function is in 3 files now (liblow.c, gpm.c,
mouse-test.c) - maybe it should be included in library?
--
Jakub Bogusz http://prioris.mini.pw.edu.pl/~qboosh/
PLD Team http://www.pld.org.pl/
--y0ulUmNC+osPPQO6
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="gpm-checkdevfsbug.patch"
--- gpm-1.19.4/liblow.c.orig Sun May 27 22:53:22 2001
+++ gpm-1.19.4/liblow.c Sat Sep 8 12:31:56 2001
@@ -183,6 +183,33 @@
}
#endif /* SIGTSTP */
+/*
+ * check for devfs
+ */
+
+static int check_devfs( void )
+{
+
+ int fd, retval = GPM_IS_NOTHING;
+
+ /* first try the devfs device, because in the next time this will be
+ * the preferred one. If that fails, take the old console */
+
+ /* Check for open new console */
+ if ((fd=open(GPM_DEVFS_CONSOLE, O_RDONLY)) >= 0)
+ retval = GPM_IS_DEVFS;
+
+ /* Failed, try OLD console */
+ else if((fd=open(GPM_NO_DEVFS_CONSOLE, O_RDONLY)) >= 0)
+ retval = GPM_IS_NOT_DEVFS;
+
+ if(fd >=0)
+ close(fd);
+
+ return retval;
+
+}
+
/*-------------------------------------------------------------------*/
int Gpm_Open(Gpm_Connect *conn, int flag)
{
@@ -196,6 +223,7 @@
/* check whether there is a devfs */
+ devfs_id = check_devfs();
switch(devfs_id)
{
--y0ulUmNC+osPPQO6--