Skip to content
10 changes: 7 additions & 3 deletions src/clients/FtpGateway.cc
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,7 @@ ftpListParseParts(const char *buf, struct Ftp::GatewayFlags flags)

while (ct && *ct) {
time_t tm;
const char* cts = nullptr;
int l = strcspn(ct, ",");
char *tmp;

Expand All @@ -707,13 +708,16 @@ ftpListParseParts(const char *buf, struct Ftp::GatewayFlags flags)
case 'm':
tm = (time_t) strtol(ct + 1, &tmp, 0);

if (tmp != ct + 1)
if (tmp == ct + 1)
break; /* not a valid integer */

cts = ctime(&tm);
if (!cts)
break;

safe_free(p->date); // TODO: properly handle multiple p->name occurrences
p->date = xstrdup(ctime(&tm));

*(strstr(p->date, "\n")) = '\0';
p->date = xstrndup(cts, strcspn(cts, "\n"));

break;

Expand Down