style: apply clang-format
CI / lint (pull_request) Failing after 2m18s
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
CI / lint (pull_request) Failing after 2m18s
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:
@@ -166,7 +166,7 @@ static int send_single_file(Client* client, File* file, Config* config, bool use
|
||||
if (!use_incremental) {
|
||||
if (use_sendfile) {
|
||||
return send_file_direct_sendfile(file, client->file_descriptor, config->use_metadata) ? 0
|
||||
: -1;
|
||||
: -1;
|
||||
}
|
||||
return send_file_direct(file, client->file_descriptor, config->use_metadata, compression_level)
|
||||
? 0
|
||||
@@ -284,8 +284,8 @@ static int send_chunks_multithreaded(void* pipeline_context) {
|
||||
} else if (context->config->use_tls) {
|
||||
client = client_create();
|
||||
if (!client || !client_connect_tls(client, context->config->server_host,
|
||||
context->config->server_port, context->config->tls_cert,
|
||||
context->config->tls_key, context->config->tls_ca)) {
|
||||
context->config->server_port, context->config->tls_cert,
|
||||
context->config->tls_key, context->config->tls_ca)) {
|
||||
if (client)
|
||||
client_delete(client);
|
||||
fprintf(stderr, "Error: could not connect to server via TLS\n");
|
||||
@@ -374,7 +374,8 @@ static int scan_directory_multithreaded(void* pipeline_context) {
|
||||
context->config->exclude_patterns, context->config->exclude_count,
|
||||
context->config->include_patterns, context->config->include_count, context->config->max_size,
|
||||
context->config->min_size, context->config->max_depth, 4, context->config->follow_symlinks,
|
||||
context->config->copy_links, context->config->safe_links, context->config->copy_unsafe_links, context->config->checksum);
|
||||
context->config->copy_links, context->config->safe_links, context->config->copy_unsafe_links,
|
||||
context->config->checksum);
|
||||
|
||||
Chunk* current_chunk;
|
||||
while ((current_chunk = parallel_scanner_next(scanner)) != NULL) {
|
||||
@@ -485,7 +486,7 @@ int send_files(Config* config) {
|
||||
} else if (config->use_tls) {
|
||||
client = client_create();
|
||||
if (!client || !client_connect_tls(client, config->server_host, config->server_port,
|
||||
config->tls_cert, config->tls_key, config->tls_ca)) {
|
||||
config->tls_cert, config->tls_key, config->tls_ca)) {
|
||||
if (client)
|
||||
client_delete(client);
|
||||
fprintf(stderr, "Error: could not connect to server via TLS\n");
|
||||
@@ -575,8 +576,8 @@ int send_files(Config* config) {
|
||||
}
|
||||
if (config->stats) {
|
||||
double rate = elapsed_total > 0 ? total_bytes / (1048576.0 * elapsed_total) : 0;
|
||||
fprintf(stderr, "Stats: %d files, %.1f MB, %.1f MB/s\n", total_files,
|
||||
total_bytes / 1048576.0, rate);
|
||||
fprintf(stderr, "Stats: %d files, %.1f MB, %.1f MB/s\n", total_files, total_bytes / 1048576.0,
|
||||
rate);
|
||||
}
|
||||
directory_scanner_destroy(scanner);
|
||||
client_disconnect(client);
|
||||
|
||||
@@ -309,12 +309,12 @@ static int parallel_worker_thread(void* arg) {
|
||||
}
|
||||
|
||||
ParallelScanner* parallel_scanner_create(char* root_directory, bool use_metadata,
|
||||
unsigned long long chunk_size, char** exclude_patterns,
|
||||
int exclude_count, char** include_patterns,
|
||||
int include_count, unsigned long long max_size,
|
||||
unsigned long long min_size, int max_depth,
|
||||
int num_threads, bool follow_symlinks, bool copy_links,
|
||||
bool safe_links, bool copy_unsafe_links, bool checksum) {
|
||||
unsigned long long chunk_size, char** exclude_patterns,
|
||||
int exclude_count, char** include_patterns,
|
||||
int include_count, unsigned long long max_size,
|
||||
unsigned long long min_size, int max_depth,
|
||||
int num_threads, bool follow_symlinks, bool copy_links,
|
||||
bool safe_links, bool copy_unsafe_links, bool checksum) {
|
||||
ParallelScanner* ps = calloc(1, sizeof(ParallelScanner));
|
||||
if (!ps)
|
||||
return NULL;
|
||||
@@ -355,8 +355,7 @@ ParallelScanner* parallel_scanner_create(char* root_directory, bool use_metadata
|
||||
bool is_symlink = S_ISLNK(lstats.st_mode);
|
||||
|
||||
// Skip symlinks unless the user explicitly enabled following/copying them.
|
||||
if (is_symlink && !follow_symlinks && !copy_links && !safe_links &&
|
||||
!copy_unsafe_links) {
|
||||
if (is_symlink && !follow_symlinks && !copy_links && !safe_links && !copy_unsafe_links) {
|
||||
free(cur_path);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -51,12 +51,12 @@ Chunk* directory_scanner_next(DirectoryScanner* scanner);
|
||||
void directory_scanner_destroy(DirectoryScanner* scanner);
|
||||
|
||||
ParallelScanner* parallel_scanner_create(char* root_directory, bool use_metadata,
|
||||
unsigned long long chunk_size, char** exclude_patterns,
|
||||
int exclude_count, char** include_patterns,
|
||||
int include_count, unsigned long long max_size,
|
||||
unsigned long long min_size, int max_depth,
|
||||
int num_threads, bool follow_symlinks, bool copy_links,
|
||||
bool safe_links, bool copy_unsafe_links, bool checksum);
|
||||
unsigned long long chunk_size, char** exclude_patterns,
|
||||
int exclude_count, char** include_patterns,
|
||||
int include_count, unsigned long long max_size,
|
||||
unsigned long long min_size, int max_depth,
|
||||
int num_threads, bool follow_symlinks, bool copy_links,
|
||||
bool safe_links, bool copy_unsafe_links, bool checksum);
|
||||
Chunk* parallel_scanner_next(ParallelScanner* scanner);
|
||||
void parallel_scanner_destroy(ParallelScanner* scanner);
|
||||
|
||||
|
||||
+4
-4
@@ -162,8 +162,8 @@ Chunk* chunk_deserialize(Data* data, bool use_metadata) {
|
||||
|
||||
// Reject individual file data larger than the maximum allowed size.
|
||||
if (file_data_size > MAX_FILE_DATA_SIZE) {
|
||||
log_message(LOG_LEVEL_ERROR, "File data size %zu exceeds maximum %llu",
|
||||
file_data_size, (unsigned long long)MAX_FILE_DATA_SIZE);
|
||||
log_message(LOG_LEVEL_ERROR, "File data size %zu exceeds maximum %llu", file_data_size,
|
||||
(unsigned long long)MAX_FILE_DATA_SIZE);
|
||||
array_list_delete(files);
|
||||
return NULL;
|
||||
}
|
||||
@@ -224,8 +224,8 @@ Chunk* receive_chunk_data(int fd, const Config* config) {
|
||||
|
||||
// Reject chunks larger than the maximum allowed size to prevent OOM.
|
||||
if (data_to_process->size > MAX_CHUNK_SIZE) {
|
||||
log_message(LOG_LEVEL_ERROR, "Chunk size %zu exceeds maximum %llu",
|
||||
data_to_process->size, (unsigned long long)MAX_CHUNK_SIZE);
|
||||
log_message(LOG_LEVEL_ERROR, "Chunk size %zu exceeds maximum %llu", data_to_process->size,
|
||||
(unsigned long long)MAX_CHUNK_SIZE);
|
||||
data_destroy(data_to_process);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+5
-5
@@ -143,7 +143,8 @@ bool file_save_to_disk(const char* root_directory, File* file, const Config* con
|
||||
}
|
||||
|
||||
char* resolved_root = NULL;
|
||||
const char* actual_root = (partial_dir && config && config->partial) ? partial_dir : root_directory;
|
||||
const char* actual_root =
|
||||
(partial_dir && config && config->partial) ? partial_dir : root_directory;
|
||||
resolved_root = realpath(actual_root, NULL);
|
||||
if (resolved_root == NULL) {
|
||||
if (mkdir_r(actual_root)) {
|
||||
@@ -223,8 +224,7 @@ bool file_save_to_disk(const char* root_directory, File* file, const Config* con
|
||||
size_t root_len = strlen(resolved_root);
|
||||
if (strncmp(resolved_dir, resolved_root, root_len) != 0 ||
|
||||
(resolved_dir[root_len] != '\0' && resolved_dir[root_len] != '/')) {
|
||||
log_message(LOG_LEVEL_ERROR, "Path escape detected: %s is outside %s", disk_path,
|
||||
actual_root);
|
||||
log_message(LOG_LEVEL_ERROR, "Path escape detected: %s is outside %s", disk_path, actual_root);
|
||||
free(resolved_dir);
|
||||
free(resolved_root);
|
||||
free(disk_path);
|
||||
@@ -518,8 +518,8 @@ File* receive_incremental_check(int fd, const Config* config, bool* skipped) {
|
||||
return file;
|
||||
}
|
||||
|
||||
bool to_disk(const char* path, const void* data, unsigned long long data_size,
|
||||
bool inplace, bool sparse) {
|
||||
bool to_disk(const char* path, const void* data, unsigned long long data_size, bool inplace,
|
||||
bool sparse) {
|
||||
char* tmp_path = NULL;
|
||||
char* directory = NULL;
|
||||
|
||||
|
||||
+2
-2
@@ -34,8 +34,8 @@ bool file_send_sendfile(File* file, int file_descriptor, bool use_metadata, int
|
||||
size_t file_content_to_buffer(File* file);
|
||||
FileMetadata* file_metadata_create(const struct stat* stats);
|
||||
void file_metadata_destroy(void* metadata);
|
||||
bool to_disk(const char* path, const void* data, unsigned long long data_size,
|
||||
bool inplace, bool sparse);
|
||||
bool to_disk(const char* path, const void* data, unsigned long long data_size, bool inplace,
|
||||
bool sparse);
|
||||
bool file_save_to_disk(const char* root_directory, File* file, const Config* config);
|
||||
File* receive_incremental_check(int fd, const Config* config, bool* skipped);
|
||||
int receive_manifest(int fd, const Config* config, int* next_status);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <threads.h>
|
||||
|
||||
PipelineContextSender* pipeline_context_sender_create(Config* config, Queue* queue_scanner,
|
||||
Queue* queue_loader) {
|
||||
Queue* queue_loader) {
|
||||
PipelineContextSender* context = malloc(sizeof(PipelineContextSender));
|
||||
if (context == NULL)
|
||||
return NULL;
|
||||
@@ -58,7 +58,7 @@ void pipeline_context_sender_destroy(PipelineContextSender* context) {
|
||||
}
|
||||
|
||||
PipelineContextReceiver* pipeline_context_receiver_create(Config* config, Queue* queue,
|
||||
int file_descriptor, SSL* ssl) {
|
||||
int file_descriptor, SSL* ssl) {
|
||||
PipelineContextReceiver* context = malloc(sizeof(PipelineContextReceiver));
|
||||
if (context == NULL)
|
||||
return NULL;
|
||||
|
||||
@@ -40,10 +40,10 @@ typedef struct PipelineContextReceiver {
|
||||
} PipelineContextReceiver;
|
||||
|
||||
PipelineContextSender* pipeline_context_sender_create(Config* config, Queue* queue_scanner,
|
||||
Queue* queue_loader);
|
||||
Queue* queue_loader);
|
||||
void pipeline_context_sender_destroy(PipelineContextSender* context);
|
||||
PipelineContextReceiver* pipeline_context_receiver_create(Config* config, Queue* queue_receiver,
|
||||
int file_descriptor, SSL* ssl);
|
||||
int file_descriptor, SSL* ssl);
|
||||
void pipeline_context_receiver_destroy(PipelineContextReceiver* context);
|
||||
int receive_thread(void* pipeline_context);
|
||||
int write_thread(void* pipeline_context);
|
||||
|
||||
Reference in New Issue
Block a user