1
1

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
Этот коммит содержится в:
Pavel Machek 2000-04-28 07:43:13 +00:00
родитель 27ac13996e
Коммит d7bf5305b1
3 изменённых файлов: 32 добавлений и 29 удалений

Просмотреть файл

@ -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> 2000-04-16 Pavel Machek <pavel@bug.ucw.cz>
* vfs.c (vfs_type): FL_NO_LOCALHASH for prevention of obscure * 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; vfs_s_inode *ino;
ino = g_new (vfs_s_inode, 1); ino = g_new0 (vfs_s_inode, 1);
if (!ino) if (!ino)
return NULL; return NULL;
ino->linkname = ino->localname = NULL;
ino->subdir = NULL;
if (initstat) if (initstat)
ino->st = *initstat; ino->st = *initstat;
ino->super = super; ino->super = super;
ino->ent = NULL;
ino->flags = 0;
ino->st.st_nlink = 0;
ino->st.st_ino = MEDATA->inode_counter++; ino->st.st_ino = MEDATA->inode_counter++;
ino->st.st_dev = MEDATA->rdev; 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; vfs_s_entry *entry;
entry = g_new (struct vfs_s_entry, 1); entry = g_new0 (struct vfs_s_entry, 1);
total_entries++; total_entries++;
if (name) if (name)
entry->name = g_strdup (name); entry->name = g_strdup (name);
else
entry->name = NULL;
entry->dir = NULL;
entry->next = NULL;
entry->prevp = NULL;
entry->ino = inode; entry->ino = inode;
entry->ino->ent = entry; entry->ino->ent = entry;
CALL (init_entry) (me, 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; vfs_s_entry *ent = NULL;
char p[MC_MAXPATHLEN] = ""; char p[MC_MAXPATHLEN] = "";
while (1){ while (root){
int t; int t;
for (pseg = 0; path [pseg] == PATH_SEP; pseg++) while (*path == PATH_SEP) /* Strip leading '/' */
; path++;
if (!path [pseg])
if (!path [0])
return ent; return ent;
path += pseg;
for (pseg = 0; path[pseg] && path[pseg] != PATH_SEP; 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; return NULL;
root = ent->ino; root = ent->ino;
} }
return NULL;
} }
static void static void
@ -276,10 +269,7 @@ split_dir_name (vfs *me, char *path, char **dir, char **name, char **save)
*save = s; *save = s;
*dir = path; *dir = path;
*s++ = 0; *s++ = 0;
if (!*s) /* This can happen if someone does stat("/"); */ *name = s;
*name = "";
else
*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; char *local, *op, *archive_name;
int result = -1; int result = -1;
struct vfs_s_super *super; struct vfs_s_super *super;
void *cookie; void *cookie = NULL;
archive_name = inname; archive_name = inname;
vfs_split (inname, &local, &op); vfs_split (inname, &local, &op);

Просмотреть файл

@ -118,7 +118,7 @@ extern char *home_dir;
/* Anonymous setup */ /* Anonymous setup */
char *ftpfs_anonymous_passwd = NULL; char *ftpfs_anonymous_passwd = NULL;
int ftpfs_directory_timeout; int ftpfs_directory_timeout = 900;
/* Proxy host */ /* Proxy host */
char *ftpfs_proxy_host = NULL; char *ftpfs_proxy_host = NULL;
@ -1254,6 +1254,7 @@ dir_load(vfs *me, vfs_s_inode *dir, char *remote_path)
} }
num_entries++; num_entries++;
if ((!strcmp(ent->name, ".")) || (!strcmp (ent->name, ".."))) { if ((!strcmp(ent->name, ".")) || (!strcmp (ent->name, ".."))) {
g_free (ent->name);
ent->name = NULL; /* Ouch, vfs_s_free_entry "knows" about . and .. being special :-( */ ent->name = NULL; /* Ouch, vfs_s_free_entry "knows" about . and .. being special :-( */
vfs_s_free_entry (me, ent); vfs_s_free_entry (me, ent);
continue; continue;
@ -1729,7 +1730,7 @@ static int netrc_next (void)
{ {
char *p; char *p;
int i; int i;
static const char * keywords [] = { "default", "machine", static const char * const keywords [] = { "default", "machine",
"login", "password", "passwd", "account", "macdef" }; "login", "password", "passwd", "account", "macdef" };
while (1) { while (1) {
@ -1863,11 +1864,13 @@ int lookup_netrc (char *host, char **login, char **pass)
if (keyword == 20) if (keyword == 20)
break; break;
} }
if (keyword == 20) if (keyword != 20)
continue;
else
break; break;
} }
g_free (netrc);
g_free (netrcname);
rupp = g_new (struct rupcache, 1); rupp = g_new (struct rupcache, 1);
rupp->host = g_strdup (host); rupp->host = g_strdup (host);
rupp->login = rupp->pass = 0; rupp->login = rupp->pass = 0;
@ -1879,8 +1882,6 @@ int lookup_netrc (char *host, char **login, char **pass)
rupp->next = rup_cache; rupp->next = rup_cache;
rup_cache = rupp; rup_cache = rupp;
g_free (netrc);
g_free (netrcname);
return 0; return 0;
} }