From b4a1100f4f81534e2aac0141afda750f318223d4 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Mon, 17 Mar 2003 01:54:37 +0000 Subject: 2003-03-16 Havoc Pennington * dbus/dbus-watch.c (_dbus_watch_new): handle failure to malloc the watch * dbus/dbus-server-debug-pipe.c (_dbus_transport_debug_pipe_new): add some missing dbus_set_result * bus/dispatch.c (bus_dispatch_add_connection): handle failure to alloc the DBusMessageHandler * dbus/dbus-transport.c (_dbus_transport_disconnect): don't ref the transport here, since we call this from the finalizer; it resulted in a double-finalize. * dbus/dbus-transport.c (_dbus_transport_disconnect): fix a bug where we tried to use transport->connection that was NULL, happened when transport was disconnected early on due to OOM * bus/*.c: adapt to handle OOM for watches/timeouts * dbus/dbus-transport-unix.c: port to handle OOM during watch handling * dbus/dbus-auth.c (_dbus_auth_get_unused_bytes): return a reference to unused bytes instead of a copy * dbus/dbus-server.c (dbus_server_handle_watch): return FALSE for out of memory * dbus/dbus-connection.c (dbus_connection_handle_watch): return FALSE on OOM * dbus/dbus-timeout.c (dbus_timeout_handle): return FALSE for out of memory --- dbus/dbus-auth-script.c | 46 ++++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) (limited to 'dbus/dbus-auth-script.c') diff --git a/dbus/dbus-auth-script.c b/dbus/dbus-auth-script.c index 336d63e1..d954c8dd 100644 --- a/dbus/dbus-auth-script.c +++ b/dbus/dbus-auth-script.c @@ -437,14 +437,23 @@ _dbus_auth_script_run (const DBusString *filename) _dbus_string_free (&username); } } - - if (!_dbus_auth_bytes_received (auth, &to_send)) - { - _dbus_warn ("not enough memory to call bytes_received, or can't add bytes to auth object already in end state\n"); - _dbus_string_free (&to_send); - goto out; - } + { + DBusString *buffer; + + _dbus_auth_get_buffer (auth, &buffer); + if (!_dbus_string_copy (&to_send, 0, + buffer, _dbus_string_get_length (buffer))) + { + _dbus_warn ("not enough memory to call bytes_received, or can't add bytes to auth object already in end state\n"); + _dbus_string_free (&to_send); + _dbus_auth_return_buffer (auth, buffer, 0); + goto out; + } + + _dbus_auth_return_buffer (auth, buffer, _dbus_string_get_length (&to_send)); + } + _dbus_string_free (&to_send); } else if (_dbus_string_starts_with_c_str (&line, @@ -510,7 +519,7 @@ _dbus_auth_script_run (const DBusString *filename) "EXPECT_UNUSED")) { DBusString expected; - DBusString unused; + const DBusString *unused; _dbus_string_delete_first_word (&line); @@ -528,35 +537,20 @@ _dbus_auth_script_run (const DBusString *filename) goto out; } - if (!_dbus_string_init (&unused, _DBUS_INT_MAX)) - { - _dbus_warn ("no mem to allocate string unused\n"); - _dbus_string_free (&expected); - goto out; - } - - if (!_dbus_auth_get_unused_bytes (auth, &unused)) - { - _dbus_warn ("couldn't get unused bytes\n"); - _dbus_string_free (&expected); - _dbus_string_free (&unused); - goto out; - } + _dbus_auth_get_unused_bytes (auth, &unused); - if (_dbus_string_equal (&expected, &unused)) + if (_dbus_string_equal (&expected, unused)) { _dbus_string_free (&expected); - _dbus_string_free (&unused); } else { const char *e1, *h1; _dbus_string_get_const_data (&expected, &e1); - _dbus_string_get_const_data (&unused, &h1); + _dbus_string_get_const_data (unused, &h1); _dbus_warn ("Expected unused bytes '%s' and have '%s'\n", e1, h1); _dbus_string_free (&expected); - _dbus_string_free (&unused); goto out; } } -- cgit