summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoss Lagerwall <rosslagerwall@gmail.com>2015-02-28 12:38:45 +0000
committerRoss Lagerwall <rosslagerwall@gmail.com>2015-03-08 09:06:36 +0000
commit93fbba7d28c98101498975c53ba57e2527037710 (patch)
treeee203cfe9f21e6586ecac322eb4a23bb92f84f01
parent3b568ef0ab8d6119b3a28d0632c7967286c97f04 (diff)
downloadgvfs-93fbba7d28c98101498975c53ba57e2527037710.tar.gz
ftp: Fix directory parsing error on AIX.
Fix from upstream: http://hg.mozilla.org/mozilla-central/rev/b623418ab1de https://bugzilla.mozilla.org/show_bug.cgi?id=543805 https://bugzilla.gnome.org/show_bug.cgi?id=601583
-rw-r--r--daemon/ParseFTPList.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/daemon/ParseFTPList.c b/daemon/ParseFTPList.c
index 2d2ce0f4..0bd64b83 100644
--- a/daemon/ParseFTPList.c
+++ b/daemon/ParseFTPList.c
@@ -1196,12 +1196,21 @@ int ParseFTPList(const char *line, struct list_state *state,
} /* time/year */
- // there is exacly 1 space between filename and previous token in all
- // outputs except old Hellsoft
- if (!is_old_Hellsoft)
- result->fe_fname = tokens[tokmarker+3] + toklen[tokmarker+3] + 1;
- else
- result->fe_fname = tokens[tokmarker+4];
+ // The length of the whole date string should be 12. On AIX the length
+ // is only 11 when the year is present in the date string and there is
+ // 1 padding space at the end of the string. In both cases the filename
+ // starts at offset 13 from the start of the date string.
+ // Don't care about leading spaces when the date string has different
+ // format or when old Hellsoft output was detected.
+ {
+ const char *date_start = tokens[tokmarker+1];
+ const char *date_end = tokens[tokmarker+3] + toklen[tokmarker+3];
+ if (!is_old_Hellsoft && ((date_end - date_start) == 12 ||
+ ((date_end - date_start) == 11 && date_end[1] == ' ')))
+ result->fe_fname = date_start + 13;
+ else
+ result->fe_fname = tokens[tokmarker+4];
+ }
result->fe_fnlen = (&(line[linelen]))
- (result->fe_fname);