From 64fca85cc4b13ad2302a6c49c7fcafe1fc00c264 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Fri, 16 Apr 2021 17:47:12 -0400 Subject: [PATCH] fix: correct socket address lifetime error --- runtime/include/sandbox_request.h | 22 +++++++++++----------- runtime/src/sandbox.c | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/runtime/include/sandbox_request.h b/runtime/include/sandbox_request.h index 264bfa5..e22f7f4 100644 --- a/runtime/include/sandbox_request.h +++ b/runtime/include/sandbox_request.h @@ -13,13 +13,13 @@ #include "sandbox_state.h" struct sandbox_request { - uint64_t id; - struct module * module; - char * arguments; - int socket_descriptor; - struct sockaddr *socket_address; - uint64_t request_arrival_timestamp; /* cycles */ - uint64_t absolute_deadline; /* cycles */ + uint64_t id; + struct module * module; + char * arguments; + int socket_descriptor; + struct sockaddr socket_address; + uint64_t request_arrival_timestamp; /* cycles */ + uint64_t absolute_deadline; /* cycles */ /* * Unitless estimate of the instantaneous fraction of system capacity required to run the request @@ -74,10 +74,10 @@ sandbox_request_allocate(struct module *module, char *arguments, int socket_desc /* Sets the ID to the value before the increment */ sandbox_request->id = sandbox_request_count_postfix_increment(); - sandbox_request->module = module; - sandbox_request->arguments = arguments; - sandbox_request->socket_descriptor = socket_descriptor; - sandbox_request->socket_address = (struct sockaddr *)socket_address; + sandbox_request->module = module; + sandbox_request->arguments = arguments; + sandbox_request->socket_descriptor = socket_descriptor; + memcpy(&sandbox_request->socket_address, socket_address, sizeof(struct sockaddr)); sandbox_request->request_arrival_timestamp = request_arrival_timestamp; sandbox_request->absolute_deadline = request_arrival_timestamp + module->relative_deadline; diff --git a/runtime/src/sandbox.c b/runtime/src/sandbox.c index a6fcd83..a90bddd 100644 --- a/runtime/src/sandbox.c +++ b/runtime/src/sandbox.c @@ -476,7 +476,7 @@ sandbox_set_as_initialized(struct sandbox *sandbox, struct sandbox_request *sand sandbox->absolute_deadline = sandbox_request->absolute_deadline; sandbox->arguments = (void *)sandbox_request->arguments; sandbox->client_socket_descriptor = sandbox_request->socket_descriptor; - memcpy(&sandbox->client_address, sandbox_request->socket_address, sizeof(struct sockaddr)); + memcpy(&sandbox->client_address, &sandbox_request->socket_address, sizeof(struct sockaddr)); sandbox->last_state_change_timestamp = allocation_timestamp; /* We use arg to include alloc */ sandbox->state = SANDBOX_INITIALIZED;