sd-varlink: refuse accepting more than 253 fds to send along with a Varlink message

253 is the max number of fds one can send at once on a Linux AF_UNIX
socket. Hence refuse to send more early.
This commit is contained in:
Lennart Poettering
2025-04-25 19:58:22 +02:00
parent a4c81a6509
commit 92c52a9ba6

View File

@@ -3112,8 +3112,8 @@ _public_ int sd_varlink_push_fd(sd_varlink *v, int fd) {
if (!v->allow_fd_passing_output)
return -EPERM;
if (v->n_pushed_fds >= INT_MAX)
return -ENOMEM;
if (v->n_pushed_fds >= SCM_MAX_FD) /* Kernel doesn't support more than 253 fds per message, refuse early hence */
return -ENOBUFS;
if (!GREEDY_REALLOC(v->pushed_fds, v->n_pushed_fds + 1))
return -ENOMEM;