diff --git a/Makefile b/Makefile index 801cacb..cb35cd8 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,7 @@ MAKEFLAGS += --no-print-directory #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project #--------------------------------------------------------------------------------- -LIBS := -lgcc -lgd -lpng -lz -lfreetype -lvorbisidec -lfat -liosuhax +LIBS := -lgcc -lfat -liosuhax #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing diff --git a/src/fs/fs_utils.c b/src/fs/fs_utils.c index efa2e55..613cec6 100644 --- a/src/fs/fs_utils.c +++ b/src/fs/fs_utils.c @@ -95,9 +95,9 @@ int LoadFileToMem(const char *filepath, u8 **inbuffer, u32 *size) *inbuffer = buffer; //! sign is optional input - if(size) + if(size) { *size = filesize; - + } return filesize; } diff --git a/src/main.c b/src/main.c index cef6945..cbe2fa0 100644 --- a/src/main.c +++ b/src/main.c @@ -222,7 +222,7 @@ int Menu_Main(void) OSScreenFlipBuffersEx(0); OSScreenFlipBuffersEx(1); - console_printf("FTPiiU v0.4 is listening on %u.%u.%u.%u:%i", (network_gethostip() >> 24) & 0xFF, (network_gethostip() >> 16) & 0xFF, (network_gethostip() >> 8) & 0xFF, (network_gethostip() >> 0) & 0xFF, PORT); + console_printf("FTPiiU v0.4u2 is listening on %u.%u.%u.%u:%i", (network_gethostip() >> 24) & 0xFF, (network_gethostip() >> 16) & 0xFF, (network_gethostip() >> 8) & 0xFF, (network_gethostip() >> 0) & 0xFF, PORT); int serverSocket = create_server(PORT); diff --git a/src/vrt.c b/src/vrt.c index e4ed863..dedf1f7 100644 --- a/src/vrt.c +++ b/src/vrt.c @@ -154,6 +154,16 @@ char *to_real_path(char *virtual_cwd, char *virtual_path) { return path; } +static int checkdir(char *path) { + DIR *dir = opendir(path); + if(dir) + { + closedir(dir); + return 0; + } + return -1; +} + typedef void * (*path_func)(char *path, ...); static void *with_virtual_path(void *virtual_cwd, void *void_f, char *virtual_path, s32 failed, ...) { @@ -205,13 +215,23 @@ int vrt_stat(char *cwd, char *path, struct stat *st) { return (int)with_virtual_path(cwd, stat, path, -1, st, NULL); } +static int vrt_checkdir(char *cwd, char *path) { + char *real_path = to_real_path(cwd, path); + if (!real_path) + { + return -1; + } + else if (!*real_path || (strcmp(path, ".") == 0) || (strlen(cwd) == 1) || ((strlen(cwd) > 1) && (strcmp(path, "..") == 0))) + { + return 0; + } + free(real_path); + return (int)with_virtual_path(cwd, checkdir, path, -1, NULL); +} + int vrt_chdir(char *cwd, char *path) { - struct stat st; - if (vrt_stat(cwd, path, &st)) { - return -1; - } else if (!(st.st_mode & S_IFDIR)) { - errno = ENOTDIR; + if (vrt_checkdir(cwd, path)) { return -1; } char *abspath = virtual_abspath(cwd, path);