diff --git a/proto/methods.c b/proto/methods.c index 93eeadd..bccc63b 100644 --- a/proto/methods.c +++ b/proto/methods.c @@ -557,7 +557,7 @@ static int save_file(int version, socket_t *socket, const char *dirname) { printf("name_len = %zi\n", (ssize_t)fname_size); #endif // limit file name length to 1024 chars - if (fname_size < 0 || fname_size > MAX_FILE_NAME_LENGTH) return EXIT_FAILURE; + if (fname_size <= 0 || fname_size > MAX_FILE_NAME_LENGTH) return EXIT_FAILURE; const uint64_t name_length = (uint64_t)fname_size; char file_name[name_length + 1]; @@ -585,6 +585,7 @@ static int save_file(int version, socket_t *socket, const char *dirname) { } } #endif + if (file_name[name_length - 1] == '/') file_name[name_length - 1] = 0; // remove trailing / char new_path[name_length + 20]; if (file_name[0] == PATH_SEP) { diff --git a/utils/net_utils.c b/utils/net_utils.c index ae91e7a..4b36e36 100644 --- a/utils/net_utils.c +++ b/utils/net_utils.c @@ -297,6 +297,7 @@ void close_socket(socket_t *socket) { switch (socket->type) { case PLAIN_SOCK: { #if defined(__linux__) || defined(__APPLE__) + shutdown(socket->socket.plain, SHUT_RD); close(socket->socket.plain); #elif defined(_WIN32) closesocket(socket->socket.plain);