]> git.ipfire.org Git - thirdparty/systemd.git/commit
socket-util: introduce CMSG_FIND_AND_COPY_DATA()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 13 Apr 2023 09:00:41 +0000 (18:00 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 16 Apr 2023 04:26:55 +0000 (13:26 +0900)
commit4836f4c67d040f51b7d1aa45b73553eb0da26097
tree3d915ffc81ad3d9ab83c8f112bc24489c8f40b3a
parent1113e50796315a2aaaf768a243e3788cdb4aac78
socket-util: introduce CMSG_FIND_AND_COPY_DATA()

The cmd(3) man page says about CMSG_DATA():
> The pointer returned cannot be assumed to be suitably aligned for
> accessing arbitrary payload data types. Applications should not cast
> it to a pointer type matching the payload, but should instead use
> memcpy(3) to copy data to or from a suitably declared object.

Hence, if we want to use unaligned data in cmsg, we need to copy it
before use. That's typically important for reading timestamps in
RISCV32, as the time_t is 64bit and size_t is 32bit on the system.
src/basic/socket-util.c
src/basic/socket-util.h