sd-daemon: add fd array size safety check to sd_notify_with_fds()
The previous commit removed the UINT_MAX check for the fd array. Let's now re-add one, but at a better place, and with a more useful limit. As it turns out the kernel does not allow passing more than 253 fds at the same time, hence use that as limit. And do so immediately before calculating the control buffer size, so that we catch multiplication overflows.
This commit is contained in:
@@ -68,3 +68,10 @@
|
||||
#ifndef IPV6_RECVFRAGSIZE
|
||||
#define IPV6_RECVFRAGSIZE 77
|
||||
#endif
|
||||
|
||||
/* The maximum number of fds that SCM_RIGHTS accepts. This is an internal kernel constant, but very much
|
||||
* useful for userspace too. It's documented in unix(7) these days, hence should be fairly reliable to define
|
||||
* here. */
|
||||
#ifndef SCM_MAX_FD
|
||||
#define SCM_MAX_FD 253U
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user