Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix (potential) crashes in LVM DBus init #1012

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/plugins/lvm-dbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ static gboolean setup_dbus_connection (GError **error) {

addr = g_dbus_address_get_for_bus_sync (G_BUS_TYPE_SYSTEM, NULL, error);
if (!addr) {
bd_utils_log_format (BD_UTILS_LOG_CRIT, "Failed to get system bus address: %s\n", (*error)->message);
g_prefix_error (error, "Failed to get system bus address: ");
return FALSE;
}

Expand All @@ -267,8 +267,14 @@ static gboolean setup_dbus_connection (GError **error) {

g_free (addr);

if (!bus || g_dbus_connection_is_closed (bus)) {
bd_utils_log_format (BD_UTILS_LOG_CRIT, "Failed to create a new connection for the system bus: %s\n", (*error)->message);
if (!bus) {
g_prefix_error (error, "Failed to create a new connection for the system bus: ");
return FALSE;
}

if (g_dbus_connection_is_closed (bus)) {
g_set_error (error, BD_LVM_ERROR, BD_LVM_ERROR_FAIL,
"Connection is closed");
return FALSE;
}

Expand Down Expand Up @@ -336,6 +342,7 @@ gboolean bd_lvm_init (void) {
completely rely on it */
if (G_UNLIKELY (!bus) && !setup_dbus_connection (&error)) {
bd_utils_log_format (BD_UTILS_LOG_CRIT, "Failed to setup DBus connection: %s", error->message);
g_clear_error (&error);
return FALSE;
}

Expand Down
Loading