dbus-monitor: do not leak file descriptors from fd-passing
authorAlban Crequy <alban.crequy@collabora.co.uk>
Fri, 27 Jun 2014 15:33:39 +0000 (16:33 +0100)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 15 Sep 2014 16:37:34 +0000 (17:37 +0100)
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=80603
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
tools/dbus-print-message.c

index e0dd2da..320abd6 100644 (file)
@@ -352,6 +352,13 @@ print_iter (DBusMessageIter *iter, dbus_bool_t literal, int depth)
            int fd;
            dbus_message_iter_get_basic (iter, &fd);
            printf ("unix fd %d\n", fd);
+
+            /* dbus_message_iter_get_basic() duplicated the fd, we need to
+             * close it after use. The original fd will be closed when the
+             * DBusMessage is released.
+             */
+            close (fd);
+
            break;
          }