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
d5d9eec2b5 but was a bug long
before that commit happened anyway.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user