fix: address all 7 review issues
CI / lint (pull_request) Failing after 3s
CI / build-and-test (pull_request) Has been skipped
CI / sanitizers (address) (pull_request) Has been skipped
CI / sanitizers (undefined) (pull_request) Has been skipped
CI / fuzz-build (pull_request) Has been skipped
CI / coverage (pull_request) Has been skipped
CI / valgrind (pull_request) Has been skipped

This commit is contained in:
2026-07-21 18:06:48 +02:00
parent 415adf2077
commit a70ce5c4af
294 changed files with 23333 additions and 11 deletions
+15 -6
View File
@@ -112,11 +112,18 @@ int main(int argc, char* argv[]) {
save_to_disk = true;
}
Config* config = config_create(str_dup(PROTOCOL_VERSION), NULL, NULL, save_to_disk, false, false,
false, false, 5, false, 0);
int exit_code = 0;
Config* config = NULL;
bool config_owned_by_pipeline = false;
char* config_version = str_dup(PROTOCOL_VERSION);
if (!config_version) {
exit_code = 1;
goto cleanup;
}
config = config_create(config_version, NULL, NULL, save_to_disk, false, false, false,
false, 5, false, 0);
int positional_args[2];
int positional_count = 0;
@@ -409,9 +416,11 @@ int main(int argc, char* argv[]) {
}
cleanup:
if (config->log_file)
fclose(config->log_file);
if (!config_owned_by_pipeline)
config_delete(config);
if (config) {
if (config->log_file)
fclose(config->log_file);
if (!config_owned_by_pipeline)
config_delete(config);
}
return exit_code;
}
+3
View File
@@ -14,6 +14,8 @@ Config* config_create(char* version, char* send_directory, char* receive_directo
bool use_sendfile, unsigned long long chunk_size) {
Config* config = malloc(sizeof(Config));
if (!config)
return NULL;
config->version = version;
config->send_directory = send_directory;
config->receive_root_directory = receive_directory;
@@ -259,6 +261,7 @@ error:
free(config->send_directory);
free(config->receive_root_directory);
free(config->server_host);
free(config->backup_dir);
free(config);
return NULL;
}
+10
View File
@@ -85,6 +85,11 @@ bool send_n_data(int file_descriptor, const void* data, size_t data_size) {
else
bytes_send = write(fd, (const char*)data + total_bytes_send, chunk);
if (bytes_send <= 0) {
if (io_ssl) {
int ssl_err = SSL_get_error(io_ssl, (int)bytes_send);
if (ssl_err == SSL_ERROR_WANT_WRITE || ssl_err == SSL_ERROR_WANT_READ)
continue;
}
log_message(LOG_LEVEL_ERROR, "Could not send data");
return false;
}
@@ -121,6 +126,11 @@ bool receive_n_data(int file_descriptor, void* data, size_t data_size) {
bytes_received =
read(fd, (char*)data + total_bytes_received, data_size - total_bytes_received);
if (bytes_received <= 0) {
if (io_ssl) {
int ssl_err = SSL_get_error(io_ssl, (int)bytes_received);
if (ssl_err == SSL_ERROR_WANT_WRITE || ssl_err == SSL_ERROR_WANT_READ)
continue;
}
if (bytes_received == 0)
log_message(LOG_LEVEL_ERROR, "Connection closed while receiving data");
else
+2 -2
View File
@@ -12,7 +12,7 @@
#include <sys/wait.h>
#include <unistd.h>
static volatile unsigned int g_active_connections = 0;
static volatile sig_atomic_t g_active_connections = 0;
static void sigchld_handler(int sig) {
(void)sig;
@@ -92,7 +92,7 @@ static void accept_loop(Server* server, void (*child_fn)(int, void*), void* chil
perror("Could not accept the connection");
continue;
}
if (g_active_connections >= server->max_connections) {
if ((unsigned int)g_active_connections >= server->max_connections) {
log_message(LOG_LEVEL_WARNING, "Max connections (%u) reached, rejecting",
server->max_connections);
close(fd);