chiark / gitweb /
sd-bus: correct size calculation in DBus fd receive
authorMichal Schmidt <mschmidt@redhat.com>
Wed, 16 Sep 2015 20:55:02 +0000 (22:55 +0200)
committerSven Eden <yamakuzure@gmx.net>
Wed, 29 Mar 2017 08:45:09 +0000 (10:45 +0200)
The size of the allocated array for received file descriptors was
incorrectly calculated. This did not matter when a single file
descriptor was received, but for more descriptors the allocation was
insufficient.

src/libelogind/sd-bus/bus-socket.c

index 735a775cb4bd77e97703d957c23918fa7ca21a9c..d0b1e3d7dc69873c8e6a727ae9198c903df0e7b1 100644 (file)
@@ -985,7 +985,7 @@ int bus_socket_read_message(sd_bus *bus) {
                                         return -EIO;
                                 }
 
-                                f = realloc(bus->fds, sizeof(int) + (bus->n_fds + n));
+                                f = realloc(bus->fds, sizeof(int) * (bus->n_fds + n));
                                 if (!f) {
                                         close_many((int*) CMSG_DATA(cmsg), n);
                                         return -ENOMEM;