chiark / gitweb /
sd-bus: let's better not invade stdio territory when duplicating fds
authorLennart Poettering <lennart@poettering.net>
Wed, 28 Feb 2018 22:36:33 +0000 (23:36 +0100)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:59:13 +0000 (07:59 +0200)
src/libelogind/sd-bus/bus-message.c

index 5c91757aac802c766bd3bd7bc0cdd4d47fcdb31a..a0e4bc4277d926582aa205ee466ed73c8ca5aa09 100644 (file)
@@ -1400,7 +1400,7 @@ static int message_push_fd(sd_bus_message *m, int fd) {
         if (copy < 0)
                 return -errno;
 
-        f = reallocarray(m->fds, sizeof(int), m->n_fds + 1);
+        f = realloc(m->fds, sizeof(int) * (m->n_fds + 1));
         if (!f) {
                 m->poisoned = true;
                 safe_close(copy);
@@ -2646,7 +2646,7 @@ _public_ int sd_bus_message_append_array_memfd(
         if (r < 0)
                 return r;
 
-        copy_fd = dup(memfd);
+        copy_fd = fcntl(memfd, F_DUPFD_CLOEXEC, 3);
         if (copy_fd < 0)
                 return copy_fd;
 
@@ -2721,7 +2721,7 @@ _public_ int sd_bus_message_append_string_memfd(
         if (r < 0)
                 return r;
 
-        copy_fd = dup(memfd);
+        copy_fd = fcntl(memfd, FD_CLOEXEC, 3);
         if (copy_fd < 0)
                 return copy_fd;