Commit 9a3145b9 authored by John Palmieri's avatar John Palmieri

These are all patches from Kjartan Maraas <kmaraas at gnome dot org>

with cleanups of bugs found from Coverity reports:

* dbus/dbus-sysdeps-util.c (_dbus_write_pid_file):
  close the file on error to avoid a leak

* bus/expirelist.c (bus_expire_list_test):
  Check for NULL on dbus_new0

* bus/activation.c (update_directory):
  remove dead code

* bus/config-parser.c (merge_service_context_hash, start_selinux_child):
  Fix some leaks

* bus/bus.c (process_config_every_time):
  Fixed a leak

* bus/desktop-file.c (parse_key_value):
  Fixed leak

* bus/selinux.c (bus_selinux_id_table_insert):
  Fixed leak
parent 1fa8e404
2006-08-08 John (J5) Palmieri <johnp@redhat.com>
These are all patches from Kjartan Maraas <kmaraas at gnome dot org>
with cleanups of bugs found from Coverity reports:
* dbus/dbus-sysdeps-util.c (_dbus_write_pid_file):
close the file on error to avoid a leak
* bus/expirelist.c (bus_expire_list_test):
Check for NULL on dbus_new0
* bus/activation.c (update_directory):
remove dead code
* bus/config-parser.c (merge_service_context_hash, start_selinux_child):
Fix some leaks
* bus/bus.c (process_config_every_time):
Fixed a leak
* bus/desktop-file.c (parse_key_value):
Fixed leak
* bus/selinux.c (bus_selinux_id_table_insert):
Fixed leak
2006-08-08 John (J5) Palmieri <johnp@redhat.com>
* dbus/dbus-object-tree.c (_dbus_object_subtree_new):
......
......@@ -633,8 +633,6 @@ update_directory (BusActivation *activation,
if (iter != NULL)
_dbus_directory_close (iter);
if (desktop_file)
bus_desktop_file_free (desktop_file);
_dbus_string_free (&filename);
_dbus_string_free (&full_path);
......
......@@ -402,11 +402,13 @@ process_config_every_time (BusContext *context,
{
DBusString full_address;
DBusList *link;
char *addr;
dbus_bool_t retval;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
addr = NULL;
retval = FALSE;
if (!_dbus_string_init (&full_address))
......@@ -427,8 +429,6 @@ process_config_every_time (BusContext *context,
link = _dbus_list_get_last_link (&context->servers);
while (link != NULL)
{
char *addr;
addr = dbus_server_get_address (link->data);
if (addr == NULL)
{
......@@ -452,6 +452,7 @@ process_config_every_time (BusContext *context,
}
dbus_free (addr);
addr = NULL;
link = _dbus_list_get_prev_link (&context->servers, link);
}
......@@ -489,6 +490,10 @@ process_config_every_time (BusContext *context,
failed:
_dbus_string_free (&full_address);
if (addr)
dbus_free (addr)
return retval;
}
......
......@@ -248,27 +248,42 @@ merge_service_context_hash (DBusHashTable *dest,
DBusHashTable *from)
{
DBusHashIter iter;
char *service_copy;
char *context_copy;
service_copy = NULL;
context_copy = NULL;
_dbus_hash_iter_init (from, &iter);
while (_dbus_hash_iter_next (&iter))
{
const char *service = _dbus_hash_iter_get_string_key (&iter);
const char *context = _dbus_hash_iter_get_value (&iter);
char *service_copy;
char *context_copy;
service_copy = _dbus_strdup (service);
if (service_copy == NULL)
return FALSE;
goto fail;
context_copy = _dbus_strdup (context);
if (context_copy == NULL)
return FALSE;
goto fail;
if (!_dbus_hash_table_insert_string (dest, service_copy, context_copy))
return FALSE;
goto fail;
service_copy = NULL;
context_copy = NULL;
}
return TRUE;
fail:
if (service_copy)
dbus_free (service_copy);
if (context_copy)
dbus_free (context_copy);
return FALSE;
}
static dbus_bool_t
......@@ -1542,12 +1557,16 @@ start_selinux_child (BusConfigParser *parser,
const char **attribute_values,
DBusError *error)
{
char *own_copy;
char *context_copy;
own_copy = NULL;
context_copy = NULL;
if (strcmp (element_name, "associate") == 0)
{
const char *own;
const char *context;
char *own_copy;
char *context_copy;
if (!locate_attributes (parser, "associate",
attribute_names,
......@@ -1573,18 +1592,15 @@ start_selinux_child (BusConfigParser *parser,
own_copy = _dbus_strdup (own);
if (own_copy == NULL)
return FALSE;
goto oom;
context_copy = _dbus_strdup (context);
if (context_copy == NULL)
return FALSE;
goto oom;
if (!_dbus_hash_table_insert_string (parser->service_context_table,
own_copy, context_copy))
{
BUS_SET_OOM (error);
return FALSE;
}
goto oom;
return TRUE;
}
else
......@@ -1594,6 +1610,16 @@ start_selinux_child (BusConfigParser *parser,
element_name, "selinux");
return FALSE;
}
oom:
if (own_copy)
dbus_free (own_copy);
if (context_copy)
dbus_free (context_copy);
BUS_SET_OOM (error);
return FALSE;
}
dbus_bool_t
......
......@@ -525,12 +525,14 @@ parse_key_value (BusDesktopFileParser *parser, DBusError *error)
line = new_line (parser);
if (line == NULL)
{
dbus_free (value);
parser_free (parser);
return FALSE;
}
if (!_dbus_string_init (&key))
{
dbus_free (value);
parser_free (parser);
return FALSE;
}
......@@ -538,12 +540,14 @@ parse_key_value (BusDesktopFileParser *parser, DBusError *error)
if (!_dbus_string_copy_len (&parser->data, key_start, key_end - key_start,
&key, 0))
{
dbus_free (value);
parser_free (parser);
return FALSE;
}
if (!_dbus_string_steal_data (&key, &tmp))
{
dbus_free (value);
parser_free (parser);
return FALSE;
}
......
......@@ -248,7 +248,9 @@ bus_expire_list_test (const DBusString *test_data_dir)
long tv_sec_past, tv_usec_past;
TestExpireItem *item;
int next_interval;
dbus_bool_t result = FALSE;
loop = _dbus_loop_new ();
_dbus_assert (loop != NULL);
......@@ -276,6 +278,9 @@ bus_expire_list_test (const DBusString *test_data_dir)
item = dbus_new0 (TestExpireItem, 1);
if (item == NULL)
goto oom;
item->item.added_tv_sec = tv_sec;
item->item.added_tv_usec = tv_usec;
if (!_dbus_list_append (&list->items, item))
......@@ -308,7 +313,10 @@ bus_expire_list_test (const DBusString *test_data_dir)
bus_expire_list_free (list);
_dbus_loop_unref (loop);
return TRUE;
result = TRUE;
oom:
return result;
}
#endif /* DBUS_BUILD_TESTS */
......@@ -756,7 +756,11 @@ bus_selinux_id_table_insert (DBusHashTable *service_table,
if (avc_context_to_sid ((char *) service_context, &sid) < 0)
{
if (errno == ENOMEM)
return FALSE;
{
dbus_free (key);
return FALSE;
}
_dbus_warn ("Error getting SID from context \"%s\": %s\n",
(char *) service_context,
_dbus_strerror (errno));
......
......@@ -219,6 +219,8 @@ _dbus_write_pid_file (const DBusString *filename,
dbus_set_error (error, _dbus_error_from_errno (errno),
"Failed to write to \"%s\": %s", cfilename,
_dbus_strerror (errno));
fclose (f);
return FALSE;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment