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:10:56 +0000
commit125df9c92a6671f69a1d79094de676c7124d0691 (patch)
treebd1d9a406f7422e1d5e096a1f2dcae5f90a896dd
parent14369db2a8fc4f2a33e457a766b077ed6e2a3557 (diff)
downloadgvfs-125df9c92a6671f69a1d79094de676c7124d0691.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);