]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-daemon: count array elements in size_t
authorLennart Poettering <lennart@poettering.net>
Mon, 4 Nov 2024 10:01:23 +0000 (11:01 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 4 Nov 2024 10:02:38 +0000 (11:02 +0100)
We fucked that up in the original sd_listen() calls, and then we fixed
that on the newer flavours. But pour internal common implementation
should of course use the full range size_t, as it should be.

This then allows us to drop a redundant range check.

src/libsystemd/sd-daemon/sd-daemon.c

index 26e4257a1ffecc153d9fd5740520294af184fc32..faf45c27509298a7b6e6c1c2159a2d19ad6bd065 100644 (file)
@@ -457,7 +457,7 @@ static int pid_notify_with_fds_internal(
                 pid_t pid,
                 const char *state,
                 const int *fds,
-                unsigned n_fds) {
+                size_t n_fds) {
 
         SocketAddress address;
         struct iovec iovec;
@@ -728,16 +728,7 @@ _public_ int sd_pid_notifyf_with_fds(
         _cleanup_free_ char *p = NULL;
         int r;
 
-        /* Paranoia check: we traditionally used 'unsigned' as array size, but we nowadays more correctly use
-         * 'size_t'. sd_pid_notifyf_with_fds() and sd_pid_notify_with_fds() are from different eras, hence
-         * differ in this. Let's catch resulting incompatibilites early, even though they are pretty much
-         * theoretic only */
-        if (n_fds > UINT_MAX) {
-                r = -E2BIG;
-                goto finish;
-        }
-
-        else if (format) {
+        if (format) {
                 va_list ap;
 
                 va_start(ap, format);