aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2011-12-07 17:07:46 -0600
committerDan Williams <dcbw@redhat.com>2011-12-07 17:07:46 -0600
commit2af1a612e9187c0e2bf3a8e3d007f04aa023add9 (patch)
treef3a864e6521e8459bf1bb76840e534bb01f002e3
parentc1e64f1a33b8b877945e59bda58b1969cdc27614 (diff)
core: don't crash on error if response is NULL
Various bits of the code didn't check if response was valid or not during error conditions, and when an error occurs sometimes it'll be NULL (since not all errors are translated errors from the modem, some are serial or general ones). We have to make sure we don't try to use response->str when response doesn't exist. Found in the generic CDMA code likely as a result of d5d9eec2b52363a7460aeec0c020b1c6a7af6b03 but was a bug long before that commit happened anyway.
-rw-r--r--plugins/mm-modem-mbm.c4
-rw-r--r--plugins/mm-plugin-longcheer.c3
-rw-r--r--plugins/mm-plugin-x22x.c3
-rw-r--r--src/mm-generic-cdma.c5
-rw-r--r--src/mm-generic-gsm.c2
-rw-r--r--src/mm-modem-base.c3
6 files changed, 13 insertions, 7 deletions
diff --git a/plugins/mm-modem-mbm.c b/plugins/mm-modem-mbm.c
index 61499100..65283e47 100644
--- a/plugins/mm-modem-mbm.c
+++ b/plugins/mm-modem-mbm.c
@@ -730,7 +730,9 @@ enap_poll_response (MMAtSerialPort *port,
count = GPOINTER_TO_UINT (mm_callback_info_get_data (info, "mbm-enap-poll-count"));
- if (sscanf (response->str, "*ENAP: %d", &state) == 1 && state == 1) {
+ if ( response
+ && sscanf (response->str, "*ENAP: %d", &state) == 1
+ && state == 1) {
/* Success! Connected... */
mm_generic_gsm_connect_complete (MM_GENERIC_GSM (info->modem), NULL, info);
return;
diff --git a/plugins/mm-plugin-longcheer.c b/plugins/mm-plugin-longcheer.c
index 8124edd4..1570cf4b 100644
--- a/plugins/mm-plugin-longcheer.c
+++ b/plugins/mm-plugin-longcheer.c
@@ -72,12 +72,13 @@ custom_init_response_cb (MMPluginBaseSupportsTask *task,
guint32 *out_level,
gpointer user_data)
{
- const char *p = response->str;
+ const char *p;
if (error)
return tries <= 4 ? TRUE : FALSE;
/* Note the lack of a ':' on the GMR; the X200 doesn't send one */
+ g_assert (response);
p = mm_strip_tag (response->str, "AT+GMR");
if (*p == 'L') {
/* X200 modems have a GMR firmware revision that starts with 'L', and
diff --git a/plugins/mm-plugin-x22x.c b/plugins/mm-plugin-x22x.c
index 059bb51e..10a1b4c8 100644
--- a/plugins/mm-plugin-x22x.c
+++ b/plugins/mm-plugin-x22x.c
@@ -70,12 +70,13 @@ custom_init_response_cb (MMPluginBaseSupportsTask *task,
guint32 *out_level,
gpointer user_data)
{
- const char *p = response->str;
+ const char *p;
if (error)
return tries <= 4 ? TRUE : FALSE;
/* Note the lack of a ':' on the GMR; the X200 doesn't send one */
+ g_assert (response);
p = mm_strip_tag (response->str, "AT+GMR");
if (*p != 'L') {
/* X200 modems have a GMR firmware revision that starts with 'L', and
diff --git a/src/mm-generic-cdma.c b/src/mm-generic-cdma.c
index 371cd66e..58ced39b 100644
--- a/src/mm-generic-cdma.c
+++ b/src/mm-generic-cdma.c
@@ -988,7 +988,6 @@ get_signal_quality_done (MMAtSerialPort *port,
{
MMGenericCdmaPrivate *priv;
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
- char *reply = response->str;
/* If the modem has already been removed, return without
* scheduling callback */
@@ -1008,6 +1007,7 @@ get_signal_quality_done (MMAtSerialPort *port,
return;
}
} else {
+ const char *reply = response->str;
int quality, ber;
/* Got valid reply */
@@ -1273,7 +1273,7 @@ serving_system_done (MMAtSerialPort *port,
gpointer user_data)
{
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
- char *reply = response->str;
+ char *reply;
int class = 0, sid = 99999, num;
unsigned char band = 'Z';
gboolean success = FALSE;
@@ -1288,6 +1288,7 @@ serving_system_done (MMAtSerialPort *port,
goto out;
}
+ reply = response->str;
if (strstr (reply, "+CSS: "))
reply += 6;
diff --git a/src/mm-generic-gsm.c b/src/mm-generic-gsm.c
index c41e9f2a..6c7b938c 100644
--- a/src/mm-generic-gsm.c
+++ b/src/mm-generic-gsm.c
@@ -350,7 +350,7 @@ pin_check_done (MMAtSerialPort *port,
info->error = g_error_new (MM_MODEM_ERROR,
MM_MODEM_ERROR_GENERAL,
"Could not parse PIN request response '%s'",
- response->str);
+ response ? response->str : "(unknown)");
}
}
diff --git a/src/mm-modem-base.c b/src/mm-modem-base.c
index 526eb51e..372367a9 100644
--- a/src/mm-modem-base.c
+++ b/src/mm-modem-base.c
@@ -553,9 +553,10 @@ info_item_done (MMCallbackInfo *info,
const char *tag2,
const char *desc)
{
- const char *p = response->str;
+ const char *p;
if (!error) {
+ p = response->str;
if (tag)
p = mm_strip_tag (p, tag);
if (tag2)