mirror of
https://github.com/systemd/systemd.git
synced 2024-12-25 01:34:28 +03:00
manager: be stricter with incomining notifications, warn properly about too large ones
Let's make the kernel let us know the full, original datagram size of the incoming message. If it's larger than the buffer space provided by us, drop the whole message with a warning. Before this change the kernel would truncate the message for us to the buffer space provided, and we'd not complain about this, and simply process the incomplete message as far as it made sense.
This commit is contained in:
parent
c55ae51e77
commit
045a3d5989
@ -1720,7 +1720,7 @@ static int manager_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = recvmsg(m->notify_fd, &msghdr, MSG_DONTWAIT|MSG_CMSG_CLOEXEC);
|
n = recvmsg(m->notify_fd, &msghdr, MSG_DONTWAIT|MSG_CMSG_CLOEXEC|MSG_TRUNC);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
if (IN_SET(errno, EAGAIN, EINTR))
|
if (IN_SET(errno, EAGAIN, EINTR))
|
||||||
return 0; /* Spurious wakeup, try again */
|
return 0; /* Spurious wakeup, try again */
|
||||||
@ -1761,7 +1761,7 @@ static int manager_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((size_t) n >= sizeof(buf)) {
|
if ((size_t) n >= sizeof(buf) || (msghdr.msg_flags & MSG_TRUNC)) {
|
||||||
log_warning("Received notify message exceeded maximum size. Ignoring.");
|
log_warning("Received notify message exceeded maximum size. Ignoring.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user