fix: leaks
This commit is contained in:
parent
8e6dec0237
commit
00ef44ac08
|
@ -116,6 +116,7 @@ int pack_elf64(t_map file) {
|
|||
|
||||
t_payload64 payload = get_xor_payload64();
|
||||
ft_printf("info: using %s algorithm\n", payload.algo_name);
|
||||
free(payload.algo_name);
|
||||
// This should fallback to compression algorithm, or smaller payload (eg rsa->xor)
|
||||
if (payload.len > (size_t)code_cave.size) {
|
||||
printf("code cave size: %ld (0x%lx) bytes\n", code_cave.size, code_cave.size);
|
||||
|
@ -140,20 +141,21 @@ int pack_elf64(t_map file) {
|
|||
}
|
||||
ft_memcpy(payload.data + payload.private_key_offset, key, sizeof(uint64_t));
|
||||
payload.encrypt(file, key, *load_segment);
|
||||
free(key);
|
||||
}
|
||||
|
||||
elf_header->e_entry = code_cave.data - file.data;
|
||||
load_segment->p_filesz += payload.len;
|
||||
load_segment->p_memsz += payload.len;
|
||||
load_segment->p_flags |= PF_W | PF_R;
|
||||
ft_memcpy(code_cave.data, payload.data, payload.len);
|
||||
free(payload.data);
|
||||
|
||||
int fd = open("woody", O_WRONLY | O_CREAT, 0755);
|
||||
if (fd == -1) {
|
||||
return wdy_perror("woody");
|
||||
}
|
||||
write(fd, file.data, file.size);
|
||||
|
||||
munmap(file.data, file.size);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue