From 0e348bad2a9348ed0838e5dca3c1c046168bcc63 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Fri, 11 Mar 2011 18:20:42 -0600 Subject: [PATCH] wimax: fix dbus-glib assert when wimax strength overflows Ran into a case right underneath a tower where the Intel WiMAX SDK reported signal strength as 32767 which is pretty clearly an overflow of a 16-bit int somewhere in the WiMAX stack. Since our internal NMWimaxNsp GObject property for signal-quality has a max value of 100, dbus-glib got pretty angry when GObject failed to return something because the property value was out of range, leading to malformed message and the bus daemon kicking us off, and finally an assertion somewhere. Fun. --- src/wimax/nm-device-wimax.c | 2 +- src/wimax/nm-wimax-nsp.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wimax/nm-device-wimax.c b/src/wimax/nm-device-wimax.c index b30f94725a..9564db3e80 100644 --- a/src/wimax/nm-device-wimax.c +++ b/src/wimax/nm-device-wimax.c @@ -1075,7 +1075,7 @@ wmx_scan_result_cb (struct wmxsdk *wmxsdk, if (net_type != nm_wimax_nsp_get_network_type (nsp)) g_object_set (nsp, NM_WIMAX_NSP_NETWORK_TYPE, net_type, NULL); - signalq = sdk_nsp->linkQuality; + signalq = CLAMP (sdk_nsp->linkQuality, 0, 100); if (signalq != nm_wimax_nsp_get_signal_quality (nsp)) g_object_set (nsp, NM_WIMAX_NSP_SIGNAL_QUALITY, signalq, NULL); diff --git a/src/wimax/nm-wimax-nsp.c b/src/wimax/nm-wimax-nsp.c index e1c9bb885a..b10cee3990 100644 --- a/src/wimax/nm-wimax-nsp.c +++ b/src/wimax/nm-wimax-nsp.c @@ -146,7 +146,7 @@ set_property (GObject *object, guint prop_id, case PROP_SIGNAL_QUALITY: quality = g_value_get_uint (value); if (quality != priv->signal_quality) { - priv->signal_quality = quality; + priv->signal_quality = CLAMP (quality, 0, 100); g_object_notify (object, NM_WIMAX_NSP_SIGNAL_QUALITY); } break;