Fix some potential aliasing issues

This commit is contained in:
Vincent Penquerc'h 2014-02-15 07:14:23 -05:00 committed by Marek Marczykowski-Górecki
parent 2b95581928
commit 36c8885ff2
2 changed files with 3 additions and 3 deletions

View File

@ -139,7 +139,7 @@ void handle_daemon_data(int s)
{ {
int status; int status;
struct client_header hdr; struct client_header hdr;
char buf[MAX_DATA_CHUNK]; char buf[MAX_DATA_CHUNK], *bufptr=buf;
if (!read_all(s, &hdr, sizeof hdr)) { if (!read_all(s, &hdr, sizeof hdr)) {
perror("read daemon"); perror("read daemon");
@ -176,7 +176,7 @@ void handle_daemon_data(int s)
write_all(2, buf, hdr.len); write_all(2, buf, hdr.len);
break; break;
case MSG_SERVER_TO_CLIENT_EXIT_CODE: case MSG_SERVER_TO_CLIENT_EXIT_CODE:
status = *(unsigned int *) buf; status = *(unsigned int *) bufptr;
if (WIFEXITED(status)) if (WIFEXITED(status))
do_exit(WEXITSTATUS(status)); do_exit(WEXITSTATUS(status));
else else

View File

@ -384,7 +384,7 @@ void get_packet_data_from_agent_and_pass_to_client(int client_id, struct client_
char buf[sizeof(*hdr) + len]; char buf[sizeof(*hdr) + len];
/* make both the header and data be consecutive in the buffer */ /* make both the header and data be consecutive in the buffer */
*(struct client_header *) buf = *hdr; memcpy(buf, hdr, sizeof(*hdr));
read_all_vchan_ext(buf + sizeof(*hdr), len); read_all_vchan_ext(buf + sizeof(*hdr), len);
if (clients[client_id].state & CLIENT_EXITED) if (clients[client_id].state & CLIENT_EXITED)
// ignore data for no longer running client // ignore data for no longer running client