We'd leak fds on early return. We are sending a message to ourself,
so it's unlikely to fail. But let's keep the logic correct.
Reported by qarmin (Rafał Mikrut).
if (n != sizeof(child_pid)) {
log_warning("Got pidref message of unexpected size %zi (expected %zu), ignoring.", n, sizeof(child_pid));
+ cmsg_close_all(&msghdr);
return 0;
}
}
}
+ /* From this point on, the fds are owned by our local variables. Call cmsg_close_all no more. */
+
/* Verify and set parent pidref. */
if (!ucred || !pid_is_valid(ucred->pid)) {
log_warning("Received pidref message without valid credentials. Ignoring.");