Skip to content

Commit

Permalink
Fix v3 send files with trailing / for dir
Browse files Browse the repository at this point in the history
  • Loading branch information
thevindu-w committed Jun 19, 2024
1 parent 197e29d commit 226b77e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion proto/methods.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions utils/net_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 226b77e

Please sign in to comment.