Re: bug #8974 overview: smbfs segmentation fault



-- 
Regards,
Andrew V. Samoilov.
vfs/ChangeLog:

2004-09-27  Andrew V. Samoilov  <sav bcs zp ua>

	* smbfs.c (smbfs_forget): Check smbfs_connections[i].cli
	to avoid possible segmentation fault.  Close
	https://savannah.gnu.org/bugs/index.php?func=detailitem&item_id=8974

--- smbfs.c.bak	Mon Sep 27 09:29:26 2004
+++ smbfs.c	Mon Sep 27 16:47:00 2004
@@ -1695,13 +1695,13 @@ static void
 smbfs_forget (const char *path)
 {
     char *host, *user, *p;
-    int  port, i;
+    int port, i;
 
     if (strncmp (path, URL_HEADER, HEADER_LEN))
-		return;
+	return;
+
+    DEBUG (3, ("smbfs_forget(path:%s)\n", path));
 
-	DEBUG(3, ("smbfs_forget(path:%s)\n", path));
-    
     path += 6;
     if (path[0] == '/' && path[1] == '/')
 	path += 2;
@@ -1709,17 +1709,18 @@ smbfs_forget (const char *path)
     if ((p = smbfs_get_host_and_username (&path, &host, &user, &port, NULL))) {
 	g_free (p);
 	for (i = 0; i < SMBFS_MAX_CONNECTIONS; i++) {
-		if ((strcmp (host, smbfs_connections [i].host) == 0) &&
-		    (strcmp (user, smbfs_connections [i].user) == 0) &&
-		    (port == smbfs_connections [i].port)) {
-
-		    /* close socket: the child owns it now */
-		    cli_shutdown(smbfs_connections [i].cli);
-
-		    /* reopen the connection */
-		    smbfs_connections [i].cli =
-				smbfs_do_connect(host, smbfs_connections[i].service);
-		}
+	    if (smbfs_connections[i].cli
+		&& (strcmp (host, smbfs_connections[i].host) == 0)
+		&& (strcmp (user, smbfs_connections[i].user) == 0)
+		&& (port == smbfs_connections[i].port)) {
+
+		/* close socket: the child owns it now */
+		cli_shutdown (smbfs_connections[i].cli);
+
+		/* reopen the connection */
+		smbfs_connections[i].cli =
+		    smbfs_do_connect (host, smbfs_connections[i].service);
+	    }
 	}
     }
     g_free (host);


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