NetworkManager/rh1029053-fix-crash-device-no-MAC.patch
Jiří Klimeš b75568ba24 cherry-picked several fixes (for crashes)
- dispatcher: fix crash on exit while logging from signal handler (rh #1017884)
- core: workaround crash when connecting to wifi (rh #1025371)
- ethernet: don't crash if device doesn't have a MAC address (rh #1029053)
- libnm-glib: fix crash by taking additional ref in result_cb() (rh #1030403)
- ifcfg-rh: fix ignoring updates that don't change anything
2013-11-20 14:41:57 +01:00

74 lines
2.7 KiB
Diff

From 696f655d7c7b605d0344aeb6ba4ff643cd46a5b4 Mon Sep 17 00:00:00 2001
From: Dan Williams <dcbw@redhat.com>
Date: Mon, 11 Nov 2013 15:43:13 -0600
Subject: [PATCH] ethernet: don't crash if device doesn't have a MAC address
(rh #1029053)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Like IBM s390 CTC devices, which aren't really ethernet but for
historical reasons we treat them as such.
Signed-off-by: Jiří Klimeš <jklimes@redhat.com>
Updated to apply for Fedora 20 snapshot.
---
src/devices/nm-device-ethernet.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c
index 7b1c248..c0b7861 100644
--- a/src/devices/nm-device-ethernet.c
+++ b/src/devices/nm-device-ethernet.c
@@ -310,6 +310,7 @@ update_permanent_hw_address (NMDevice *dev)
struct ifreq req;
struct ethtool_perm_addr *epaddr = NULL;
int fd, ret;
+ const guint8 *mac;
fd = socket (PF_INET, SOCK_DGRAM, 0);
if (fd < 0) {
@@ -332,7 +333,11 @@ update_permanent_hw_address (NMDevice *dev)
nm_log_dbg (LOGD_HW | LOGD_ETHER, "(%s): unable to read permanent MAC address (error %d)",
nm_device_get_iface (dev), errno);
/* Fall back to current address */
- memcpy (epaddr->data, nm_device_get_hw_address (dev, NULL), ETH_ALEN);
+ mac = nm_device_get_hw_address (dev, NULL);
+ if (mac)
+ memcpy (epaddr->data, mac, ETH_ALEN);
+ else
+ memset (epaddr->data, 0, ETH_ALEN);
}
if (memcmp (&priv->perm_hw_addr, epaddr->data, ETH_ALEN)) {
@@ -350,11 +355,14 @@ update_initial_hw_address (NMDevice *dev)
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (dev);
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
char *mac_str;
+ const guint8 *mac;
/* This sets initial MAC address from current MAC address. It should only
* be called from NMDevice constructor() to really get the initial address.
*/
- memcpy (priv->initial_hw_addr, nm_device_get_hw_address (dev, NULL), ETH_ALEN);
+ mac = nm_device_get_hw_address (dev, NULL);
+ if (mac)
+ memcpy (priv->initial_hw_addr, mac, ETH_ALEN);
mac_str = nm_utils_hwaddr_ntoa (priv->initial_hw_addr, ARPHRD_ETHER);
nm_log_dbg (LOGD_DEVICE | LOGD_ETHER, "(%s): read initial MAC address %s",
@@ -1219,7 +1219,7 @@ update_connection (NMDevice *device, NMConnection *connection)
{
NMSettingWired *s_wired = nm_connection_get_setting_wired (connection);
guint maclen;
- gconstpointer mac = nm_device_get_hw_address (device, &maclen);
+ const guint8 *mac = nm_device_get_hw_address (device, &maclen);
if (!s_wired) {
s_wired = (NMSettingWired *) nm_setting_wired_new ();
--
1.7.11.7