2000-04-05 Andrew V. Samoilov <sav@bcs.zp.ua>

* utilfs.c (vfs_split_url): don't assign *pass if pass is NULL
        * fish.c (archive_open, archive_same): memory allocated by
          vfs_split_url () must be released after use, don't strdup()
          values allocated by vfs_split_url () and NULL passed to
          vfs_split_url () when password value is unused
        * ftpfs.c (archive_open, archive_same): ditto plus same for
          ftpfs_get_proxy_host_and_port ()
This commit is contained in:
Pavel Machek 2000-04-10 12:00:43 +00:00
parent cfc69f6769
commit f5f1ec0523
4 changed files with 62 additions and 31 deletions

View File

@ -1,3 +1,13 @@
2000-04-05 Andrew V. Samoilov <sav@bcs.zp.ua>
* utilfs.c (vfs_split_url): don't assign *pass if pass is NULL
* fish.c (archive_open, archive_same): memory allocated by
vfs_split_url () must be released after use, don't strdup()
values allocated by vfs_split_url () and NULL passed to
vfs_split_url () when password value is unused
* ftpfs.c (archive_open, archive_same): ditto plus same for
ftpfs_get_proxy_host_and_port ()
2000-04-06 Timur Bakeyev <mc@bat.ru>
* ftpfs.c (netrc_next): Turned strange "const char * const keywords"

View File

@ -268,30 +268,43 @@ open_archive_int (vfs *me, vfs_s_super *super)
static int
open_archive (vfs *me, vfs_s_super *super, char *archive_name, char *op)
{
char *host, *user, *password;
char *host, *user, *password, *p;
int flags;
vfs_split_url (strchr(op, ':')+1, &host, &user, &flags, &password, 0, URL_NOSLASH);
SUP.host = g_strdup (host);
SUP.user = g_strdup (user);
p = vfs_split_url (strchr(op, ':')+1, &host, &user, &flags, &password, 0, URL_NOSLASH);
if (p)
g_free (p);
SUP.host = host;
SUP.user = user;
SUP.flags = flags;
if (!strncmp( op, "rsh:", 4 ))
SUP.flags |= FISH_FLAG_RSH;
SUP.home = NULL;
if (password)
SUP.password = g_strdup (password);
SUP.password = password;
return open_archive_int (me, super);
}
static int
archive_same(vfs *me, vfs_s_super *super, char *archive_name, char *op, void *cookie)
{
char *host, *user, *dummy2;
char *host, *user;
int flags;
vfs_split_url (strchr(op, ':')+1, &host, &user, &flags, &dummy2, 0, URL_NOSLASH);
return ((strcmp (host, SUP.host) == 0) &&
op = vfs_split_url (strchr(op, ':')+1, &host, &user, &flags, 0, 0, URL_NOSLASH);
if (op)
g_free (op);
flags = ((strcmp (host, SUP.host) == 0) &&
(strcmp (user, SUP.user) == 0) &&
(flags == SUP.flags));
g_free (host);
g_free (user);
return flags;
}
int

View File

@ -575,7 +575,7 @@ load_no_proxy_list ()
}
static int
ftpfs_check_proxy (char *host)
ftpfs_check_proxy (const char *host)
{
struct no_proxy_entry *npe;
@ -617,17 +617,15 @@ ftpfs_check_proxy (char *host)
static void
ftpfs_get_proxy_host_and_port (char *proxy, char **host, int *port)
{
char *user, *pass, *dir;
char *user, *dir;
#if defined(HSC_PROXY)
dir = vfs_split_url (proxy, host, &user, port, &pass, HSC_PROXY_PORT, URL_DEFAULTANON);
dir = vfs_split_url (proxy, host, &user, port, 0, HSC_PROXY_PORT, URL_DEFAULTANON);
#else
dir = vfs_split_url (proxy, host, &user, port, &pass, FTP_COMMAND_PORT, URL_DEFAULTANON);
dir = vfs_split_url (proxy, host, &user, port, 0, FTP_COMMAND_PORT, URL_DEFAULTANON);
#endif
g_free (user);
if (pass)
wipe_password (pass);
if (dir)
g_free (dir);
}
@ -768,10 +766,13 @@ open_archive (vfs *me, vfs_s_super *super, char *archive_name, char *op)
char *host, *user, *password;
int port;
vfs_split_url (strchr(op, ':')+1, &host, &user, &port, &password, FTP_COMMAND_PORT, URL_DEFAULTANON);
op = vfs_split_url (strchr(op, ':')+1, &host, &user, &port, &password, FTP_COMMAND_PORT, URL_DEFAULTANON);
SUP.host = g_strdup (host);
SUP.user = g_strdup (user);
if (op)
g_free (op);
SUP.host = host;
SUP.user = user;
SUP.port = port;
SUP.home = NULL;
SUP.proxy= 0;
@ -784,23 +785,33 @@ open_archive (vfs *me, vfs_s_super *super, char *archive_name, char *op)
SUP.remote_is_amiga = 0;
super->name = g_strdup("/");
#if 0
super->name = g_strconcat( "/#ftp:", SUP.user, "@", SUP.host, "/", NULL );
super->name = g_strconcat( "/#ftp:", user, "@", host, "/", NULL );
#endif
super->root = vfs_s_new_inode (me, super, vfs_s_default_stat(me, S_IFDIR | 0755));
if (password)
SUP.password = g_strdup (password);
SUP.password = password;
return open_archive_int (me, super);
}
static int
archive_same(vfs *me, vfs_s_super *super, char *archive_name, char *op, void *cookie)
{
char *host, *user, *dummy2;
char *host, *user;
int port;
vfs_split_url (strchr(op, ':')+1, &host, &user, &port, &dummy2, 21, URL_DEFAULTANON);
return ((strcmp (host, SUP.host) == 0) &&
op = vfs_split_url (strchr(op, ':')+1, &host, &user, &port, 0, 21, URL_DEFAULTANON);
if (op)
g_free (op);
port = ((strcmp (host, SUP.host) == 0) &&
(strcmp (user, SUP.user) == 0) &&
(port == SUP.port));
g_free (host);
g_free (user);
return port;
}
static int

View File

@ -56,7 +56,7 @@
* If the user is empty, e.g. ftp://@roxanne/private, then your login name
* is supplied.
*
* returns malloced host, user.
* returns malloced host, user and pass if pass is not null.
* returns a malloced strings with the pathname relative to the host.
* */
@ -70,7 +70,8 @@ char *vfs_split_url (char *path, char **host, char **user, int *port, char **pas
char *pend = pcopy + strlen (pcopy);
int default_is_anon = flags & URL_DEFAULTANON;
*pass = NULL;
if (pass)
*pass = NULL;
*port = default_port;
*user = NULL;
retval = NULL;
@ -97,9 +98,7 @@ char *vfs_split_url (char *path, char **host, char **user, int *port, char **pas
if (inner_colon){
*inner_colon = 0;
inner_colon++;
if (*inner_colon == '@')
*pass = NULL;
else
if (pass && (*inner_colon != '@'))
*pass = g_strdup (inner_colon);
}
if (*pcopy != 0)
@ -134,19 +133,17 @@ char *vfs_split_url (char *path, char **host, char **user, int *port, char **pas
if (*port <= 0 || *port >= 65536)
*port = default_port;
} else {
while(1) {
colon++;
while(*(++colon)){
switch(*colon) {
case 'C': *port = 1;
break;
case 'r': *port = 2;
break;
case 0: goto done;
}
}
}
}
done:
*host = g_strdup (rest);
g_free (pcopy);