mirror of
https://github.com/wiiu-env/ftpiiu_plugin.git
synced 2024-11-17 18:29:19 +01:00
Fix MLSD/MLST bugs
This commit is contained in:
parent
7b1176d374
commit
d00b1a8c71
17
source/ftp.c
17
source/ftp.c
@ -759,8 +759,16 @@ ftp_session_fill_dirent_type(ftp_session_t *session, const struct stat *st,
|
|||||||
if(session->mlst_flags & SESSION_MLST_MODIFY)
|
if(session->mlst_flags & SESSION_MLST_MODIFY)
|
||||||
{
|
{
|
||||||
/* mtime fact */
|
/* mtime fact */
|
||||||
|
struct tm *tm = gmtime(&st->st_mtime);
|
||||||
|
if(tm == NULL)
|
||||||
|
return errno;
|
||||||
|
|
||||||
session->buffersize +=
|
session->buffersize +=
|
||||||
sprintf(session->buffer + session->buffersize, "Modify=%ld;", st->st_mtime);
|
strftime(session->buffer + session->buffersize,
|
||||||
|
sizeof(session->buffer) - session->buffersize,
|
||||||
|
"Modify=%Y%m%d%H%M%S;", tm);
|
||||||
|
if(session->buffersize == 0)
|
||||||
|
return EOVERFLOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(session->mlst_flags & SESSION_MLST_PERM)
|
if(session->mlst_flags & SESSION_MLST_PERM)
|
||||||
@ -814,8 +822,8 @@ ftp_session_fill_dirent_type(ftp_session_t *session, const struct stat *st,
|
|||||||
{
|
{
|
||||||
/* unix mode fact */
|
/* unix mode fact */
|
||||||
mode_t mask = S_IRWXU | S_IRWXG | S_IRWXO | S_ISVTX | S_ISGID | S_ISUID;
|
mode_t mask = S_IRWXU | S_IRWXG | S_IRWXO | S_ISVTX | S_ISGID | S_ISUID;
|
||||||
session->buffersize =
|
session->buffersize +=
|
||||||
sprintf(session->buffer, "UNIX.mode=0%lo;",
|
sprintf(session->buffer + session->buffersize, "UNIX.mode=0%lo;",
|
||||||
(unsigned long)(st->st_mode & mask));
|
(unsigned long)(st->st_mode & mask));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3189,7 +3197,7 @@ FTP_DECLARE(MLST)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
path = malloc(session->buffersize);
|
path = malloc(session->buffersize + 1);
|
||||||
if(!path)
|
if(!path)
|
||||||
{
|
{
|
||||||
ftp_send_response(session, 550, "%s\r\n", strerror(ENOMEM));
|
ftp_send_response(session, 550, "%s\r\n", strerror(ENOMEM));
|
||||||
@ -3197,6 +3205,7 @@ FTP_DECLARE(MLST)
|
|||||||
}
|
}
|
||||||
|
|
||||||
memcpy(path, session->buffer, session->buffersize);
|
memcpy(path, session->buffer, session->buffersize);
|
||||||
|
path[session->buffersize] = 0;
|
||||||
ftp_send_response(session, -250, "Status\r\n%s250 End\r\n", path);
|
ftp_send_response(session, -250, "Status\r\n%s250 End\r\n", path);
|
||||||
free(path);
|
free(path);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user