[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [gftp] Re: Changing Novell servers with CWD //server
Hi,
Brian Masney wrote:
Here is a patch for expand_path() to lib/misc.c so that it won't strip off
the double slashes. Please let me know if it fixes your problem.
This patch fixes the problem. When I type "//dzin", gFTP sends the
correct command "CWD //dzin" which the Novell server recognizes and I
can then see the files on the server DZIN.
Now there is a new problem though. And it occurs on any FTP server, not
just Novell.
When the current remote directory is "/" and I try to enter a directory
called "pub" by doubleclicking on it, gFTP sends "CWD //pub".
On most FTP servers this doesn't cause any problems. They ignore the
superfluous slash. But the Novell server interprets this as a command to
switch to another Novell server and responds with:
550 File Server unavailable
I think I've found a bug in function lib/misc.c:gftp_build_path and I
have fixed it:
@@ -1229,7 +1240,7 @@
{
len = strlen (element);
- if (len > 0 && element[len - 1] == '/')
+ if (len > 0 && ret[retlen - 1] == '/')
add_separator = 0;
else
{
I'm attaching the complete patch (your gftp-novell.patch + my oneliner).
With this patch I have no more problems.
Brian
Michal
diff -Nur gftp-2.0.16pre0/lib/misc.c gftp-2.0.16pre0-mich2/lib/misc.c
--- gftp-2.0.16pre0/lib/misc.c Thu Oct 30 21:02:08 2003
+++ gftp-2.0.16pre0-mich2/lib/misc.c Tue Nov 4 21:51:33 2003
@@ -151,7 +151,8 @@
char *
expand_path (const char *src)
{
- char *str, *pos, *endpos, *prevpos, *newstr, *tempstr, tempchar;
+ char *str, *pos, *endpos, *prevpos, *newstr, *tempstr, *ntoken,
+ tempchar;
struct passwd *pw;
pw = NULL;
@@ -178,22 +179,28 @@
while ((pos = strchr (endpos, '/')) != NULL)
{
pos++;
- while (*pos == '/')
- pos++;
- if ((endpos = strchr (pos, '/')) == NULL)
+ for (ntoken = pos; *ntoken == '/'; ntoken++);
+
+ if ((endpos = strchr (ntoken, '/')) == NULL)
endpos = pos + strlen (pos);
tempchar = *endpos;
*endpos = '\0';
- if (strcmp (pos, "..") == 0)
+ if (strcmp (ntoken, "..") == 0)
{
- *(pos - 1) = '\0';
if (newstr != NULL && (prevpos = strrchr (newstr, '/')) != NULL)
- *prevpos = '\0';
+ {
+ *prevpos = '\0';
+ if (*newstr == '\0')
+ {
+ g_free (newstr);
+ newstr = NULL;
+ }
+ }
}
- else if (strcmp (pos, ".") != 0)
+ else if (strcmp (ntoken, ".") != 0)
{
if (newstr == NULL)
newstr = g_strdup (pos - 1);
@@ -215,7 +222,7 @@
if (endpos != NULL && *endpos != '\0' && newstr == NULL)
{
if (strcmp (endpos, "..") == 0)
- newstr = g_malloc0 (1);
+ newstr = g_strdup ("/");
else
newstr = g_strdup (endpos);
}
@@ -360,6 +367,10 @@
printf ("%s\n", gftp_version);
+#ifdef _REENTRANT
+ printf ("#define _REENTRANT\n");
+#endif
+
#ifdef _GNU_SOURCE
printf ("#define _GNU_SOURCE\n");
#endif
@@ -1229,7 +1240,7 @@
{
len = strlen (element);
- if (len > 0 && element[len - 1] == '/')
+ if (len > 0 && ret[retlen - 1] == '/')
add_separator = 0;
else
{