From 320caad2e16773e7c1516fc5fc52b7ce463d22f7 Mon Sep 17 00:00:00 2001 From: "Andrew V. Samoilov" Date: Tue, 28 Sep 2004 09:30:53 +0000 Subject: [PATCH] * 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 --- vfs/ChangeLog | 7 +++++++ vfs/smbfs.c | 27 ++++++++++++++------------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/vfs/ChangeLog b/vfs/ChangeLog index a3eff8d8c..0ed668cac 100644 --- a/vfs/ChangeLog +++ b/vfs/ChangeLog @@ -1,3 +1,10 @@ +2004-09-27 Andrew V. Samoilov + + * 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 + + 2004-09-26 Roland Illig * vfs.c (_vfs_get_class): Reverted my last patch because diff --git a/vfs/smbfs.c b/vfs/smbfs.c index b7cd54e55..4e0ac24b0 100644 --- a/vfs/smbfs.c +++ b/vfs/smbfs.c @@ -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)) { + 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); + /* 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); - } + /* reopen the connection */ + smbfs_connections[i].cli = + smbfs_do_connect (host, smbfs_connections[i].service); + } } } g_free (host);