mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-22 03:02:06 +03:00
2000-04-26 Andrew V. Samoilov <sav@bcs.zp.ua>
* direntry.c (vfs_s_find_entry_tree): segfault fixed when root is NULL (vfs_s_new_inode, vfs_s_new_entry): g_new replaced by g_new0 * ftpfs.c (dir_load): ent->name is free()d for "." and ".." (ftpfs_directory_timeout): default value changed to 900 (netrc_next): "const char * const keywords" go to rodata and is shared
This commit is contained in:
parent
27ac13996e
commit
d7bf5305b1
@ -1,3 +1,15 @@
|
||||
2000-04-26 Andrew V. Samoilov <sav@bcs.zp.ua>
|
||||
|
||||
* direntry.c (vfs_s_find_entry_tree): segfault fixed when root is NULL
|
||||
|
||||
(vfs_s_new_inode, vfs_s_new_entry): g_new replaced by g_new0
|
||||
|
||||
* ftpfs.c (dir_load): ent->name is free()d for "." and ".."
|
||||
|
||||
(ftpfs_directory_timeout): default value changed to 900
|
||||
|
||||
(netrc_next): "const char * const keywords" go to rodata and is shared
|
||||
|
||||
2000-04-16 Pavel Machek <pavel@bug.ucw.cz>
|
||||
|
||||
* vfs.c (vfs_type): FL_NO_LOCALHASH for prevention of obscure
|
||||
|
@ -39,18 +39,13 @@ vfs_s_new_inode (vfs *me, vfs_s_super *super, struct stat *initstat)
|
||||
{
|
||||
vfs_s_inode *ino;
|
||||
|
||||
ino = g_new (vfs_s_inode, 1);
|
||||
ino = g_new0 (vfs_s_inode, 1);
|
||||
if (!ino)
|
||||
return NULL;
|
||||
|
||||
ino->linkname = ino->localname = NULL;
|
||||
ino->subdir = NULL;
|
||||
if (initstat)
|
||||
ino->st = *initstat;
|
||||
ino->super = super;
|
||||
ino->ent = NULL;
|
||||
ino->flags = 0;
|
||||
ino->st.st_nlink = 0;
|
||||
ino->st.st_ino = MEDATA->inode_counter++;
|
||||
ino->st.st_dev = MEDATA->rdev;
|
||||
|
||||
@ -67,16 +62,12 @@ vfs_s_new_entry (vfs *me, char *name, vfs_s_inode *inode)
|
||||
{
|
||||
vfs_s_entry *entry;
|
||||
|
||||
entry = g_new (struct vfs_s_entry, 1);
|
||||
entry = g_new0 (struct vfs_s_entry, 1);
|
||||
total_entries++;
|
||||
|
||||
if (name)
|
||||
entry->name = g_strdup (name);
|
||||
else
|
||||
entry->name = NULL;
|
||||
entry->dir = NULL;
|
||||
entry->next = NULL;
|
||||
entry->prevp = NULL;
|
||||
|
||||
entry->ino = inode;
|
||||
entry->ino->ent = entry;
|
||||
CALL (init_entry) (me, entry);
|
||||
@ -231,14 +222,14 @@ vfs_s_find_entry_tree (vfs *me, vfs_s_inode *root, char *path, int follow, int f
|
||||
vfs_s_entry *ent = NULL;
|
||||
char p[MC_MAXPATHLEN] = "";
|
||||
|
||||
while (1){
|
||||
while (root){
|
||||
int t;
|
||||
|
||||
for (pseg = 0; path [pseg] == PATH_SEP; pseg++)
|
||||
;
|
||||
if (!path [pseg])
|
||||
while (*path == PATH_SEP) /* Strip leading '/' */
|
||||
path++;
|
||||
|
||||
if (!path [0])
|
||||
return ent;
|
||||
path += pseg;
|
||||
|
||||
for (pseg = 0; path[pseg] && path[pseg] != PATH_SEP; pseg++)
|
||||
;
|
||||
@ -261,6 +252,8 @@ vfs_s_find_entry_tree (vfs *me, vfs_s_inode *root, char *path, int follow, int f
|
||||
return NULL;
|
||||
root = ent->ino;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -276,10 +269,7 @@ split_dir_name (vfs *me, char *path, char **dir, char **name, char **save)
|
||||
*save = s;
|
||||
*dir = path;
|
||||
*s++ = 0;
|
||||
if (!*s) /* This can happen if someone does stat("/"); */
|
||||
*name = "";
|
||||
else
|
||||
*name = s;
|
||||
*name = s;
|
||||
}
|
||||
}
|
||||
|
||||
@ -482,7 +472,7 @@ vfs_s_get_path_mangle (vfs *me, char *inname, struct vfs_s_super **archive, int
|
||||
char *local, *op, *archive_name;
|
||||
int result = -1;
|
||||
struct vfs_s_super *super;
|
||||
void *cookie;
|
||||
void *cookie = NULL;
|
||||
|
||||
archive_name = inname;
|
||||
vfs_split (inname, &local, &op);
|
||||
|
15
vfs/ftpfs.c
15
vfs/ftpfs.c
@ -118,7 +118,7 @@ extern char *home_dir;
|
||||
|
||||
/* Anonymous setup */
|
||||
char *ftpfs_anonymous_passwd = NULL;
|
||||
int ftpfs_directory_timeout;
|
||||
int ftpfs_directory_timeout = 900;
|
||||
|
||||
/* Proxy host */
|
||||
char *ftpfs_proxy_host = NULL;
|
||||
@ -1254,6 +1254,7 @@ dir_load(vfs *me, vfs_s_inode *dir, char *remote_path)
|
||||
}
|
||||
num_entries++;
|
||||
if ((!strcmp(ent->name, ".")) || (!strcmp (ent->name, ".."))) {
|
||||
g_free (ent->name);
|
||||
ent->name = NULL; /* Ouch, vfs_s_free_entry "knows" about . and .. being special :-( */
|
||||
vfs_s_free_entry (me, ent);
|
||||
continue;
|
||||
@ -1729,7 +1730,7 @@ static int netrc_next (void)
|
||||
{
|
||||
char *p;
|
||||
int i;
|
||||
static const char * keywords [] = { "default", "machine",
|
||||
static const char * const keywords [] = { "default", "machine",
|
||||
"login", "password", "passwd", "account", "macdef" };
|
||||
|
||||
while (1) {
|
||||
@ -1863,11 +1864,13 @@ int lookup_netrc (char *host, char **login, char **pass)
|
||||
if (keyword == 20)
|
||||
break;
|
||||
}
|
||||
if (keyword == 20)
|
||||
continue;
|
||||
else
|
||||
if (keyword != 20)
|
||||
break;
|
||||
}
|
||||
|
||||
g_free (netrc);
|
||||
g_free (netrcname);
|
||||
|
||||
rupp = g_new (struct rupcache, 1);
|
||||
rupp->host = g_strdup (host);
|
||||
rupp->login = rupp->pass = 0;
|
||||
@ -1879,8 +1882,6 @@ int lookup_netrc (char *host, char **login, char **pass)
|
||||
rupp->next = rup_cache;
|
||||
rup_cache = rupp;
|
||||
|
||||
g_free (netrc);
|
||||
g_free (netrcname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user