mirror of
https://github.com/systemd/systemd.git
synced 2025-01-11 09:18:07 +03:00
tree-wide: copy timestamp data from cmsg
On RISCV32, time_t is 64bit and size_t is 32bit, hence the timestamp data in message header may not be aligned. Fixes #27241.
This commit is contained in:
parent
4836f4c67d
commit
789f5c6f70
@ -1417,7 +1417,7 @@ int server_process_datagram(
|
||||
size_t label_len = 0, m;
|
||||
Server *s = ASSERT_PTR(userdata);
|
||||
struct ucred *ucred = NULL;
|
||||
struct timeval *tv = NULL;
|
||||
struct timeval tv_buf, *tv = NULL;
|
||||
struct cmsghdr *cmsg;
|
||||
char *label = NULL;
|
||||
struct iovec iovec;
|
||||
@ -1493,10 +1493,10 @@ int server_process_datagram(
|
||||
label = CMSG_TYPED_DATA(cmsg, char);
|
||||
label_len = cmsg->cmsg_len - CMSG_LEN(0);
|
||||
} else if (cmsg->cmsg_level == SOL_SOCKET &&
|
||||
cmsg->cmsg_type == SO_TIMESTAMP &&
|
||||
cmsg->cmsg_type == SCM_TIMESTAMP &&
|
||||
cmsg->cmsg_len == CMSG_LEN(sizeof(struct timeval))) {
|
||||
assert(!tv);
|
||||
tv = CMSG_TYPED_DATA(cmsg, struct timeval);
|
||||
tv = memcpy(&tv_buf, CMSG_DATA(cmsg), sizeof(struct timeval));
|
||||
} else if (cmsg->cmsg_level == SOL_SOCKET &&
|
||||
cmsg->cmsg_type == SCM_RIGHTS) {
|
||||
assert(!fds);
|
||||
|
@ -199,9 +199,11 @@ int icmp6_receive(int fd, void *buffer, size_t size, struct in6_addr *ret_dst,
|
||||
}
|
||||
|
||||
if (cmsg->cmsg_level == SOL_SOCKET &&
|
||||
cmsg->cmsg_type == SO_TIMESTAMP &&
|
||||
cmsg->cmsg_len == CMSG_LEN(sizeof(struct timeval)))
|
||||
triple_timestamp_from_realtime(&t, timeval_load(CMSG_TYPED_DATA(cmsg, struct timeval)));
|
||||
cmsg->cmsg_type == SCM_TIMESTAMP &&
|
||||
cmsg->cmsg_len == CMSG_LEN(sizeof(struct timeval))) {
|
||||
struct timeval *tv = memcpy(&(struct timeval) {}, CMSG_DATA(cmsg), sizeof(struct timeval));
|
||||
triple_timestamp_from_realtime(&t, timeval_load(tv));
|
||||
}
|
||||
}
|
||||
|
||||
if (!triple_timestamp_is_set(&t))
|
||||
|
@ -1276,7 +1276,6 @@ static int client_receive_message(
|
||||
.msg_control = &control,
|
||||
.msg_controllen = sizeof(control),
|
||||
};
|
||||
struct cmsghdr *cmsg;
|
||||
triple_timestamp t = {};
|
||||
_cleanup_free_ DHCP6Message *message = NULL;
|
||||
struct in6_addr *server_address = NULL;
|
||||
@ -1320,12 +1319,9 @@ static int client_receive_message(
|
||||
server_address = &sa.in6.sin6_addr;
|
||||
}
|
||||
|
||||
CMSG_FOREACH(cmsg, &msg) {
|
||||
if (cmsg->cmsg_level == SOL_SOCKET &&
|
||||
cmsg->cmsg_type == SO_TIMESTAMP &&
|
||||
cmsg->cmsg_len == CMSG_LEN(sizeof(struct timeval)))
|
||||
triple_timestamp_from_realtime(&t, timeval_load(CMSG_TYPED_DATA(cmsg, struct timeval)));
|
||||
}
|
||||
struct timeval *tv = CMSG_FIND_AND_COPY_DATA(&msg, SOL_SOCKET, SCM_TIMESTAMP, struct timeval);
|
||||
if (tv)
|
||||
triple_timestamp_from_realtime(&t, timeval_load(tv));
|
||||
|
||||
if (client->transaction_id != (message->transaction_id & htobe32(0x00ffffff)))
|
||||
return 0;
|
||||
|
@ -446,7 +446,7 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re
|
||||
return 0;
|
||||
}
|
||||
|
||||
recv_time = CMSG_FIND_DATA(&msghdr, SOL_SOCKET, SCM_TIMESTAMPNS, struct timespec);
|
||||
recv_time = CMSG_FIND_AND_COPY_DATA(&msghdr, SOL_SOCKET, SCM_TIMESTAMPNS, struct timespec);
|
||||
if (!recv_time)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Packet timestamp missing.");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user