• Simon McVittie's avatar
    dbus_message_iter_open_container: Don't leak signature on failure · c462a6b3
    Simon McVittie authored
    If we run out of memory while calling _dbus_type_writer_recurse()
    (which is impossible for most contained types, but can happen for
    structs and dict-entries), then the memory we allocated in the call to
    _dbus_message_iter_open_signature() will still be allocated, and we
    have to free it in order to return to the state of the world prior to
    calling open_container().
    
    One might reasonably worry that this change can break callers that use
    this (incorrect) pattern:
    
        if (!dbus_message_iter_open_container (outer, ..., inner))
          {
            dbus_message_iter_abandon_container (outer, inner);
            goto fail;
          }
        /* now we know inner is open, and we must close it later */
    
    However, testing that pattern with _dbus_test_oom_handling()
    demonstrates that it already dies with a DBusString assertion failure
    even before this commit.
    
    This is all concerningly fragile, and I think the next step should be
    to zero out DBusMessageIter instances when they are invalidated, so
    that a "double-free" is always detected.
    Signed-off-by: Simon McVittie's avatarSimon McVittie <smcv@collabora.com>
    Reviewed-by: Philip Withnall's avatarPhilip Withnall <withnall@endlessm.com>
    Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101568
    (cherry picked from commit 031aa2ce)
    c462a6b3
Name
Last commit
Last update
..
.gitignore Loading commit data...
Makefile.am Loading commit data...
Version.in Loading commit data...
dbus-address.c Loading commit data...
dbus-address.h Loading commit data...
dbus-arch-deps.h.in Loading commit data...
dbus-asv-util.c Loading commit data...
dbus-asv-util.h Loading commit data...
dbus-auth-script.c Loading commit data...
dbus-auth-script.h Loading commit data...
dbus-auth-util.c Loading commit data...
dbus-auth.c Loading commit data...
dbus-auth.h Loading commit data...
dbus-bus.c Loading commit data...
dbus-bus.h Loading commit data...
dbus-connection-internal.h Loading commit data...
dbus-connection.c Loading commit data...
dbus-connection.h Loading commit data...
dbus-credentials-util.c Loading commit data...
dbus-credentials.c Loading commit data...
dbus-credentials.h Loading commit data...
dbus-dataslot.c Loading commit data...
dbus-dataslot.h Loading commit data...
dbus-errors.c Loading commit data...
dbus-errors.h Loading commit data...
dbus-file-unix.c Loading commit data...
dbus-file-win.c Loading commit data...
dbus-file.c Loading commit data...
dbus-file.h Loading commit data...
dbus-hash.c Loading commit data...
dbus-hash.h Loading commit data...
dbus-init-win.cpp Loading commit data...
dbus-internals.c Loading commit data...
dbus-internals.h Loading commit data...
dbus-keyring.c Loading commit data...
dbus-keyring.h Loading commit data...
dbus-list.c Loading commit data...
dbus-list.h Loading commit data...
dbus-macros.h Loading commit data...
dbus-mainloop.c Loading commit data...
dbus-mainloop.h Loading commit data...
dbus-marshal-basic.c Loading commit data...
dbus-marshal-basic.h Loading commit data...
dbus-marshal-byteswap-util.c Loading commit data...
dbus-marshal-byteswap.c Loading commit data...
dbus-marshal-byteswap.h Loading commit data...
dbus-marshal-header.c Loading commit data...
dbus-marshal-header.h Loading commit data...
dbus-marshal-recursive-util.c Loading commit data...
dbus-marshal-recursive.c Loading commit data...
dbus-marshal-recursive.h Loading commit data...
dbus-marshal-validate-util.c Loading commit data...
dbus-marshal-validate.c Loading commit data...
dbus-marshal-validate.h Loading commit data...
dbus-memory.c Loading commit data...
dbus-memory.h Loading commit data...
dbus-mempool.c Loading commit data...
dbus-mempool.h Loading commit data...
dbus-message-factory.c Loading commit data...
dbus-message-factory.h Loading commit data...
dbus-message-internal.h Loading commit data...
dbus-message-private.h Loading commit data...
dbus-message-util.c Loading commit data...
dbus-message.c Loading commit data...
dbus-message.h Loading commit data...
dbus-misc.c Loading commit data...
dbus-misc.h Loading commit data...
dbus-nonce.c Loading commit data...
dbus-nonce.h Loading commit data...
dbus-object-tree.c Loading commit data...
dbus-object-tree.h Loading commit data...
dbus-pending-call-internal.h Loading commit data...
dbus-pending-call.c Loading commit data...
dbus-pending-call.h Loading commit data...
dbus-pipe-unix.c Loading commit data...
dbus-pipe-win.c Loading commit data...
dbus-pipe.c Loading commit data...
dbus-pipe.h Loading commit data...
dbus-protocol.h Loading commit data...
dbus-resources.c Loading commit data...
dbus-resources.h Loading commit data...
dbus-server-debug-pipe.c Loading commit data...
dbus-server-debug-pipe.h Loading commit data...
dbus-server-launchd.c Loading commit data...
dbus-server-launchd.h Loading commit data...
dbus-server-protected.h Loading commit data...
dbus-server-socket.c Loading commit data...
dbus-server-socket.h Loading commit data...
dbus-server-unix.c Loading commit data...
dbus-server-unix.h Loading commit data...
dbus-server-win.c Loading commit data...
dbus-server-win.h Loading commit data...
dbus-server.c Loading commit data...
dbus-server.h Loading commit data...
dbus-sha.c Loading commit data...
dbus-sha.h Loading commit data...
dbus-shared.h Loading commit data...
dbus-shell.c Loading commit data...
dbus-shell.h Loading commit data...
dbus-signature.c Loading commit data...
dbus-signature.h Loading commit data...
dbus-socket-set-epoll.c Loading commit data...
dbus-socket-set-poll.c Loading commit data...
dbus-socket-set.c Loading commit data...
dbus-socket-set.h Loading commit data...
dbus-sockets-win.h Loading commit data...
dbus-spawn-win.c Loading commit data...
dbus-spawn.c Loading commit data...
dbus-spawn.h Loading commit data...
dbus-string-private.h Loading commit data...
dbus-string-util.c Loading commit data...
dbus-string.c Loading commit data...
dbus-string.h Loading commit data...
dbus-syntax.c Loading commit data...
dbus-syntax.h Loading commit data...
dbus-sysdeps-pthread.c Loading commit data...
dbus-sysdeps-thread-win.c Loading commit data...
dbus-sysdeps-unix.c Loading commit data...
dbus-sysdeps-unix.h Loading commit data...
dbus-sysdeps-util-unix.c Loading commit data...
dbus-sysdeps-util-win.c Loading commit data...
dbus-sysdeps-util.c Loading commit data...
dbus-sysdeps-win.c Loading commit data...
dbus-sysdeps-win.h Loading commit data...
dbus-sysdeps-wince-glue.c Loading commit data...
dbus-sysdeps-wince-glue.h Loading commit data...
dbus-sysdeps.c Loading commit data...
dbus-sysdeps.h Loading commit data...
dbus-test-main.c Loading commit data...
dbus-test.c Loading commit data...
dbus-test.h Loading commit data...
dbus-threads-internal.h Loading commit data...
dbus-threads.c Loading commit data...
dbus-threads.h Loading commit data...
dbus-timeout.c Loading commit data...
dbus-timeout.h Loading commit data...
dbus-transport-protected.h Loading commit data...
dbus-transport-socket.c Loading commit data...
dbus-transport-socket.h Loading commit data...
dbus-transport-unix.c Loading commit data...
dbus-transport-unix.h Loading commit data...
dbus-transport-win.c Loading commit data...
dbus-transport-win.h Loading commit data...
dbus-transport.c Loading commit data...
dbus-transport.h Loading commit data...
dbus-types.h Loading commit data...
dbus-userdb-util.c Loading commit data...
dbus-userdb.c Loading commit data...
dbus-userdb.h Loading commit data...
dbus-uuidgen.c Loading commit data...
dbus-uuidgen.h Loading commit data...
dbus-valgrind-internal.h Loading commit data...
dbus-watch.c Loading commit data...
dbus-watch.h Loading commit data...
dbus.h Loading commit data...
versioninfo.rc.in Loading commit data...