Merge remaining 4 PRs: memory safety, refactoring, test coverage, integration cleanup #93
@@ -14,6 +14,7 @@ Config* config_create(char* version, char* send_directory, char* receive_directo
|
|||||||
bool use_sendfile, unsigned long long chunk_size) {
|
bool use_sendfile, unsigned long long chunk_size) {
|
||||||
|
|
||||||
Config* config = malloc(sizeof(Config));
|
Config* config = malloc(sizeof(Config));
|
||||||
|
if (config == NULL) return NULL;
|
||||||
config->version = version;
|
config->version = version;
|
||||||
config->send_directory = send_directory;
|
config->send_directory = send_directory;
|
||||||
config->receive_root_directory = receive_directory;
|
config->receive_root_directory = receive_directory;
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ File* file_create(const char* path) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(file->path, path);
|
memcpy(file->path, path, path_len + 1);
|
||||||
file->data = data_create_reserve(0);
|
file->data = data_create_reserve(0);
|
||||||
if (file->data == NULL) {
|
if (file->data == NULL) {
|
||||||
free(file->path);
|
free(file->path);
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ FileMetadata* metadata_from_buf(char** buf) {
|
|||||||
if (!present)
|
if (!present)
|
||||||
return NULL;
|
return NULL;
|
||||||
FileMetadata* m = malloc(sizeof(FileMetadata));
|
FileMetadata* m = malloc(sizeof(FileMetadata));
|
||||||
|
if (m == NULL) return NULL;
|
||||||
int32_t mode;
|
int32_t mode;
|
||||||
memcpy(&mode, *buf, sizeof(mode));
|
memcpy(&mode, *buf, sizeof(mode));
|
||||||
*buf += sizeof(mode);
|
*buf += sizeof(mode);
|
||||||
|
|||||||
+1
-1
@@ -54,7 +54,7 @@ char* str_dup(const char* string) {
|
|||||||
if (string == NULL)
|
if (string == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
char* new_string = (char*)malloc(strlen(string) + 1);
|
char* new_string = (char*)malloc(strlen(string) + 1);
|
||||||
strcpy(new_string, string);
|
memcpy(new_string, string, strlen(string) + 1);
|
||||||
return new_string;
|
return new_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user