File nm-gerror-must-be-null.patch of Package NetworkManager
From: Jeff Mahoney <jeffm@suse.com>
Subject: NetworkManager: GError * must be initialized to NULL
References: bnc#757656
The glib GError API expects a GError ** that it uses to assign an
API-allocated error descriptor. It expects that the calling code
has initialized to the pointer to NULL. If the pointer is uninitialized,
it will use whatever garbage is on the stack causing crashes or,
depending on the caller, potential memory corruption.
During testing with _MALLOC_PERTURB enabled, I encountered a crash
due to this issue where error->message contained the perturb value.
The following patch fixes the remaining call sites.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
libnm-glib/nm-object.c | 2 +-
libnm-glib/nm-remote-settings.c | 2 +-
src/nm-manager.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
--- a/libnm-glib/nm-object.c
+++ b/libnm-glib/nm-object.c
@@ -1248,7 +1248,7 @@ reload_complete (NMObject *object)
NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object);
GSimpleAsyncResult *simple;
GSList *results, *iter;
- GError *error;
+ GError *error = NULL;
results = priv->reload_results;
priv->reload_results = NULL;
--- a/libnm-glib/nm-remote-settings.c
+++ b/libnm-glib/nm-remote-settings.c
@@ -109,7 +109,7 @@ static void
_nm_remote_settings_ensure_inited (NMRemoteSettings *self)
{
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
- GError *error;
+ GError *error = NULL;
if (!priv->inited) {
if (!g_initable_init (G_INITABLE (self), NULL, &error)) {
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -789,7 +789,7 @@ pending_activation_check_authorized (Pen
{
char *error_desc = NULL;
gulong sender_uid = G_MAXULONG;
- GError *error;
+ GError *error = NULL;
const char *wifi_permission = NULL;
NMConnection *connection;
NMSettings *settings;