xerpi / FTPS4

FTP server for PS4
MIT License
19 stars 28 forks source link

Crash when issuing dir or nlist command #1

Open ghost opened 8 years ago

ghost commented 8 years ago

the client receives the "150 Opening ASCII mode data transfer for LIST" and then it crashes, no file/directory is shown. Does it happen only to me ? I am launching it directly through Cturt Ps4Playground. File upload through put command works.

ghost commented 8 years ago

I have found these issues: 1) The open call (row 315 of ftp.c) always returns a valid handle even when the path does not exists (just try dir command on a non existing directory). If you add a check with the standard fopen call it works perfectly. 2) The gmtime_r always crashes even though the parameters are good (it can however be skipped to make it work). 3) The getdents function sometimes crashes (it does not happen always). I have also tried to increase the buffer to 128k, but it didn't solve the issue. 4) The stat function does not crash, but sometimes it returns a non 0 value hiding therefore some entries (it can however be patched easily)

If someone is experiencing the same issues, I think there might be some problems with the I/O functions of libPS4 of PS4-SDK.

gibbed commented 7 years ago
  1. gmtime_r crashes because it doesn't exist in libSceLibcInternal. An alternative exists as gmtime_s. This is an issue with libPS4.
  2. getdents isn't crashing (for me), although using fileno as the condition for the loop is the wrong thing. It's better to check the return of getdents which indicates the size of the data written to dentbuf.
  3. The stat() call fails because getdents returns file names only, the path needs to be built and properly passed to stat().