diff --git a/vfs/ChangeLog b/vfs/ChangeLog index a91c039ad..7ea3fa8b7 100644 --- a/vfs/ChangeLog +++ b/vfs/ChangeLog @@ -1,3 +1,9 @@ +2002-10-07 Pavel Roskin + + * direntry.c (vfs_s_resolve_symlink): Use g_snprintf() instead + of non-portable snprintf(). + Reported by Xu Qiang + 2002-10-04 Pavel Roskin * mcfs.c (mcfs_lseek): Explicity cast offset to int. This fixes diff --git a/vfs/direntry.c b/vfs/direntry.c index be1ad3e49..ac7b3b62f 100644 --- a/vfs/direntry.c +++ b/vfs/direntry.c @@ -340,8 +340,6 @@ vfs_s_find_inode (vfs *me, vfs_s_inode *root, char *path, int follow, int flags) return ent->ino; } -/* Ouch - vfs_s_resolve symlink does not work for filesystems like ftp & fish: - you may not lookup with some other root! */ vfs_s_entry * vfs_s_resolve_symlink (vfs *me, vfs_s_entry *entry, char *path, int follow) { @@ -362,25 +360,29 @@ vfs_s_resolve_symlink (vfs *me, vfs_s_entry *entry, char *path, int follow) ERRNOR (EFAULT, NULL); if (MEDATA->find_entry == vfs_s_find_entry_linear) { - if (*linkname == PATH_SEP) - return (MEDATA->find_entry) (me, entry->dir->super->root, linkname, follow - 1, 0); - else { /* FIXME: this does not work */ - char *fullpath = vfs_s_fullpath(me, entry->dir); - snprintf(buf, sizeof (buf), "%s/%s", fullpath, linkname); + if (*linkname == PATH_SEP) + return (MEDATA->find_entry) (me, entry->dir->super->root, + linkname, follow - 1, 0); + else { + char *fullpath = vfs_s_fullpath (me, entry->dir); + + g_snprintf (buf, sizeof (buf), "%s/%s", fullpath, linkname); g_free (fullpath); - return (MEDATA->find_entry) (me, entry->dir->super->root, buf, follow - 1, 0); + return (MEDATA->find_entry) (me, entry->dir->super->root, buf, + follow - 1, 0); } } /* Convert absolute paths to relative ones */ if (*linkname == PATH_SEP) { char *p, *q; + for (p = path, q = entry->ino->linkname; *p == *q; p++, q++); while (*(--q) != PATH_SEP); q++; - for (;; p++){ + for (;; p++) { p = strchr (p, PATH_SEP); - if (!p){ + if (!p) { strcat (buf, q); break; }