fix of out of bounds memory access in 2 places
This commit is contained in:
@@ -95,7 +95,7 @@ char* parse_cmd(const char *cmd, file *f){
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
out = malloc(strlen(cmd) + 1 + (strlen(f->file_name)+(count*3)) + 1);
|
out = malloc(strlen(cmd) + 1 + (strlen(f->file_name)+(count*3)) + 3);
|
||||||
|
|
||||||
pos = out;
|
pos = out;
|
||||||
if (offset) {
|
if (offset) {
|
||||||
|
|||||||
@@ -156,10 +156,11 @@ void *thread_rgt(){
|
|||||||
rgt_dir.file_count = 1;
|
rgt_dir.file_count = 1;
|
||||||
rgt_dir.file_list = malloc(sizeof(file));
|
rgt_dir.file_list = malloc(sizeof(file));
|
||||||
|
|
||||||
|
char *file_name = malloc(strlen(rgt_dir.current_file->file_name)+1);
|
||||||
|
memcpy(file_name, mid_dir.current_file->file_name, strlen(mid_dir.current_file->file_name)+1);
|
||||||
memcpy(rgt_dir.file_list, rgt_dir.current_file, sizeof(file));
|
memcpy(rgt_dir.file_list, rgt_dir.current_file, sizeof(file));
|
||||||
rgt_dir.file_list->file_name = malloc(strlen(rgt_dir.current_file->file_name)+1);
|
|
||||||
memcpy(rgt_dir.file_list->file_name, rgt_dir.current_file->file_name, strlen(rgt_dir.current_file->file_name)+1);
|
|
||||||
rgt_dir.current_file = rgt_dir.file_list;
|
rgt_dir.current_file = rgt_dir.file_list;
|
||||||
|
rgt_dir.current_file->file_name = file_name;
|
||||||
|
|
||||||
pthread_mutex_unlock(&mutex_mid);
|
pthread_mutex_unlock(&mutex_mid);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user