fix memory corruption on client due to mach vm dealloc

This commit is contained in:
Felix Kratz 2022-10-26 18:47:05 +02:00
parent 32d85ffe9b
commit 62db503302
3 changed files with 5 additions and 3 deletions

View file

@ -91,7 +91,7 @@ char* mach_send_message(mach_port_t port, char* message, uint32_t len, bool awai
msg.descriptor.address = message;
msg.descriptor.size = len * sizeof(char);
msg.descriptor.copy = MACH_MSG_VIRTUAL_COPY;
msg.descriptor.deallocate = await_response;
msg.descriptor.deallocate = false;
msg.descriptor.type = MACH_MSG_OOL_DESCRIPTOR;
mach_msg(&msg.header,

View file

@ -678,9 +678,10 @@ void handle_message_mach(struct mach_buffer* buffer) {
out:
if (rsp) fclose(rsp);
response[length] = '\0';
mach_send_message(buffer->message.header.msgh_remote_port, response,
length,
false );
length + 1,
false );
if (response) free(response);
}

View file

@ -69,6 +69,7 @@ static int client_send_message(int argc, char **argv) {
message_length,
true );
free(message);
if (!rsp) return EXIT_SUCCESS;
printf("%s", rsp);