winnermicro / micropython

MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems
https://micropython.org
MIT License
9 stars 2 forks source link

tools/ftpserver.c: Bug fixes, refactoring and improvement #18

Closed robert-hh1 closed 4 years ago

robert-hh1 commented 4 years ago

tools/ftpserver.c: Normalize path names

Path names supplied with ftp commands will be normalized, causing:

tools/ftpserver.c: Refactoring of ftpserver.c

Consisting of mostly editorial work and additional checks

Removed

Optimize LIST and NLIST

Both commands use the same function now, which is told by
a parameter which format to use. This function do_list() now
also receives a buffer for temporary strings, reducing it's stack
usage.

Always build pathname from the parameter

Since many commands use the parameter as filename, build it
always. It does not hurt, if the parameter is not a filename, since
building the path has no side effects.

Checks: Check, that the resulting path created by build_full_path() does not exceed the buffer size.

Test, that the target given with CWD exists and is a dir

Bug fixes:

robert-hh1 commented 4 years ago

I'll update that for a more concise version.