Hi, while porting KNetworkManager to NM 0.7 I found a few issues which need fixing in NM. Attached are three patches which apply cleanly against trunk.
1) allow_linking_with_cpp.patch: As the filename indicates this patch adds support for using libnm_util and libnm_glib from within C++. 2) fix_segfault.patch: This patch fixes a segfault caused by some ssid being NULL. I don't know if it is desired to have ssid's being NULL but in current trunk using my ipw2200 I've got a lot of these. 3) fix_memory_corruption.patch The most important one (it took hours to find the cause). Call to g_object_get writes a gint (4 byte) into the gint8 output buffer (1 byte) and thus overwrites some other data (in my case the last_seen property). Please have a look at the patches and commit to trunk. Thanks, Helmut
Index: libnm-util/nm-connection.h =================================================================== --- libnm-util/nm-connection.h (Revision 2656) +++ libnm-util/nm-connection.h (Arbeitskopie) @@ -8,6 +8,10 @@ GHashTable *settings; } NMConnection; +#ifdef __cplusplus +extern "C" { +#endif + NMConnection *nm_connection_new (void); NMConnection *nm_connection_new_from_hash (GHashTable *hash); void nm_connection_add_setting (NMConnection *connection, @@ -29,4 +33,8 @@ void nm_setting_parser_unregister (const char *name); +#ifdef __cplusplus +} +#endif + #endif /* NM_CONNECTION_H */ Index: libnm-util/nm-setting.h =================================================================== --- libnm-util/nm-setting.h (Revision 2656) +++ libnm-util/nm-setting.h (Arbeitskopie) @@ -21,6 +21,10 @@ NMSettingDestroyFn destroy_fn; }; +#ifdef __cplusplus +extern "C" { +#endif + gboolean nm_settings_verify (GHashTable *all_settings); GHashTable *nm_setting_to_hash (NMSetting *setting); void nm_setting_destroy (NMSetting *setting); @@ -134,5 +138,8 @@ NMSetting *nm_setting_wireless_security_new (void); NMSetting *nm_setting_wireless_security_new_from_hash (GHashTable *settings); +#ifdef __cplusplus +} +#endif #endif /* NM_SETTING_H */ Index: libnm-glib/nm-device-802-3-ethernet.h =================================================================== --- libnm-glib/nm-device-802-3-ethernet.h (Revision 2656) +++ libnm-glib/nm-device-802-3-ethernet.h (Arbeitskopie) @@ -18,6 +18,10 @@ NMDeviceClass parent; } NMDevice8023EthernetClass; +#ifdef __cplusplus +extern "C" { +#endif + GType nm_device_802_3_ethernet_get_type (void); NMDevice8023Ethernet *nm_device_802_3_ethernet_new (DBusGConnection *connection, @@ -25,4 +29,8 @@ int nm_device_802_3_ethernet_get_speed (NMDevice8023Ethernet *device); char *nm_device_802_3_ethernet_get_hw_address (NMDevice8023Ethernet *device); +#ifdef __cplusplus +} +#endif + #endif /* NM_DEVICE_802_3_ETHERNET_H */ Index: libnm-glib/nm-access-point.h =================================================================== --- libnm-glib/nm-access-point.h (Revision 2656) +++ libnm-glib/nm-access-point.h (Arbeitskopie) @@ -23,6 +23,10 @@ void (*strength_changed) (NMAccessPoint *ap, gint8 strength); } NMAccessPointClass; +#ifdef __cplusplus +extern "C" { +#endif + GType nm_access_point_get_type (void); NMAccessPoint *nm_access_point_new (DBusGConnection *connection, const char *path); @@ -36,4 +40,8 @@ guint32 nm_access_point_get_rate (NMAccessPoint *ap); int nm_access_point_get_strength (NMAccessPoint *ap); +#ifdef __cplusplus +} +#endif + #endif /* NM_ACCESS_POINT_H */ Index: libnm-glib/nm-device.h =================================================================== --- libnm-glib/nm-device.h (Revision 2656) +++ libnm-glib/nm-device.h (Arbeitskopie) @@ -27,6 +27,10 @@ void (*state_changed) (NMDevice *device, NMDeviceState state); } NMDeviceClass; +#ifdef __cplusplus +extern "C" { +#endif + GType nm_device_get_type (void); NMDevice *nm_device_new (DBusGConnection *connection, @@ -49,4 +53,8 @@ NMDeviceType nm_device_type_for_path (DBusGConnection *connection, const char *path); +#ifdef __cplusplus +} +#endif + #endif /* NM_DEVICE_H */ Index: libnm-glib/nm-ip4-config.h =================================================================== --- libnm-glib/nm-ip4-config.h (Revision 2656) +++ libnm-glib/nm-ip4-config.h (Arbeitskopie) @@ -21,6 +21,10 @@ NMObjectClass parent; } NMIP4ConfigClass; +#ifdef __cplusplus +extern "C" { +#endif + GType nm_ip4_config_get_type (void); NMIP4Config *nm_ip4_config_new (DBusGConnection *connection, @@ -36,5 +40,8 @@ char *nm_ip4_config_get_nis_domain (NMIP4Config *config); GArray *nm_ip4_config_get_nis_servers (NMIP4Config *config); +#ifdef __cplusplus +} +#endif #endif /* NM_IP4_CONFIG_H */ Index: libnm-glib/nm-client.h =================================================================== --- libnm-glib/nm-client.h (Revision 2656) +++ libnm-glib/nm-client.h (Arbeitskopie) @@ -36,6 +36,10 @@ void (*vpn_state_change) (NMClient *client, NMVPNActStage state); } NMClientClass; +#ifdef __cplusplus +extern "C" { +#endif + GType nm_client_get_type (void); @@ -62,4 +66,8 @@ NMVPNActStage nm_client_get_vpn_state (NMClient *client); +#ifdef __cplusplus +} +#endif + #endif /* NM_CLIENT_H */ Index: libnm-glib/nm-device-802-11-wireless.h =================================================================== --- libnm-glib/nm-device-802-11-wireless.h (Revision 2656) +++ libnm-glib/nm-device-802-11-wireless.h (Arbeitskopie) @@ -23,6 +23,10 @@ void (*network_removed) (NMDevice80211Wireless *device, NMAccessPoint *ap); } NMDevice80211WirelessClass; +#ifdef __cplusplus +extern "C" { +#endif + GType nm_device_802_11_wireless_get_type (void); NMDevice80211Wireless *nm_device_802_11_wireless_new (DBusGConnection *connection, @@ -39,4 +43,8 @@ GSList *nm_device_802_11_wireless_get_networks (NMDevice80211Wireless *device); +#ifdef __cplusplus +} +#endif + #endif /* NM_DEVICE_802_11_WIRELESS_H */
Index: src/NetworkManagerAP.c =================================================================== --- src/NetworkManagerAP.c (Revision 2656) +++ src/NetworkManagerAP.c (Arbeitskopie) @@ -189,6 +189,7 @@ char hw_addr_buf[20]; GArray * ssid; int i; + int len; switch (prop_id) { case PROP_CAPABILITIES: @@ -198,8 +199,9 @@ g_value_set_boolean (value, !(priv->capabilities & NM_802_11_CAP_PROTO_NONE)); break; case PROP_SSID: - ssid = g_array_sized_new (FALSE, TRUE, sizeof (unsigned char), priv->ssid->len); - for (i = 0; i < priv->ssid->len; i++) + if (priv->ssid) len = priv->ssid->len; else len = 0; + ssid = g_array_sized_new (FALSE, TRUE, sizeof (unsigned char), len); + for (i = 0; i < len; i++) g_array_append_val (ssid, priv->ssid->data[i]); g_value_set_boxed (value, ssid); g_array_free (ssid, TRUE);
Index: src/NetworkManagerAP.c =================================================================== --- src/NetworkManagerAP.c (Revision 2656) +++ src/NetworkManagerAP.c (Arbeitskopie) @@ -677,13 +677,13 @@ */ gint8 nm_ap_get_strength (NMAccessPoint *ap) { - gint8 strength; + gint strength; g_return_val_if_fail (NM_IS_AP (ap), 0); g_object_get (ap, NM_AP_STRENGTH, &strength, NULL); - return strength; + return (gint8)strength; } void nm_ap_set_strength (NMAccessPoint *ap, const gint8 strength)
_______________________________________________ NetworkManager-list mailing list NetworkManager-list@gnome.org http://mail.gnome.org/mailman/listinfo/networkmanager-list