diff --git a/src/plugins/intel/mm-bearer-xmm7360.c b/src/plugins/intel/mm-bearer-xmm7360.c index 7ca3ad0e..e5d41444 100644 --- a/src/plugins/intel/mm-bearer-xmm7360.c +++ b/src/plugins/intel/mm-bearer-xmm7360.c @@ -274,12 +274,22 @@ get_dns_ready (MMBroadbandModemXmm7360 *modem, arg = (Xmm7360RpcMsgArg *) g_ptr_array_index (response->content, i + 1); if (XMM7360_RPC_MSG_ARG_GET_INT (arg) == 1) { arg = (Xmm7360RpcMsgArg *) g_ptr_array_index (response->content, i); - g_assert (arg->size >= 4); + if (arg->size < 4) { + g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, + "Unexpected DNSv4 address format"); + g_object_unref (task); + return; + } g_ptr_array_add (ctx->dns, g_inet_address_new_from_bytes ((const guint8 *)arg->value.string, G_SOCKET_FAMILY_IPV4)); } else if (XMM7360_RPC_MSG_ARG_GET_INT (arg) == 2) { arg = (Xmm7360RpcMsgArg *) g_ptr_array_index (response->content, i); - g_assert (arg->size >= 16); + if (arg->size < 16) { + g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, + "Unexpected DNSv6 address format"); + g_object_unref (task); + return; + } g_ptr_array_add (ctx->dns, g_inet_address_new_from_bytes ((const guint8 *)arg->value.string, G_SOCKET_FAMILY_IPV6)); } @@ -458,7 +468,12 @@ net_attach_command_ready (MMBroadbandModemXmm7360 *modem, /* status code */ arg = (Xmm7360RpcMsgArg *) g_ptr_array_index (response->content, 1); - g_assert (arg->type == XMM7360_RPC_MSG_ARG_TYPE_LONG); + if (arg->type != XMM7360_RPC_MSG_ARG_TYPE_LONG) { + g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, + "Unexpected net attach command response"); + g_object_unref (task); + return; + } status = XMM7360_RPC_MSG_ARG_GET_INT (arg); if (status != (gint32)0xffffffff) { diff --git a/src/plugins/intel/mm-broadband-modem-xmm7360.c b/src/plugins/intel/mm-broadband-modem-xmm7360.c index 3f9260c9..fc366228 100644 --- a/src/plugins/intel/mm-broadband-modem-xmm7360.c +++ b/src/plugins/intel/mm-broadband-modem-xmm7360.c @@ -472,8 +472,7 @@ fcc_unlock_ready (MMBroadbandModem *self, return; } arg = (Xmm7360RpcMsgArg *) g_ptr_array_index (response->content, 0); - g_assert (arg->type == XMM7360_RPC_MSG_ARG_TYPE_LONG); - if (XMM7360_RPC_MSG_ARG_GET_INT (arg) != 1) { + if ((arg->type != XMM7360_RPC_MSG_ARG_TYPE_LONG) || (XMM7360_RPC_MSG_ARG_GET_INT (arg) != 1)) { g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "Our answer to the FCC unlock challenge was not accepted"); g_object_unref (task); @@ -496,7 +495,7 @@ fcc_unlock_challenge_ready (MMBroadbandModem *self, Xmm7360RpcMsgArg *arg; gint32 fcc_challenge; GChecksum *checksum; - guchar salt[] = { 0x3d, 0xf8, 0xc7, 0x19 }; + const guchar salt[] = { 0x3d, 0xf8, 0xc7, 0x19 }; guint8 digest[32] = { 0 }; gsize digest_len = 32; g_autoptr(GByteArray) digest_response = NULL; @@ -512,7 +511,12 @@ fcc_unlock_challenge_ready (MMBroadbandModem *self, } arg = (Xmm7360RpcMsgArg *) g_ptr_array_index (response->content, 1); - g_assert (arg->type == XMM7360_RPC_MSG_ARG_TYPE_LONG); + if (arg->type != XMM7360_RPC_MSG_ARG_TYPE_LONG) { + g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, + "Unexpected response to FCC unlock challenge request"); + g_object_unref (task); + return; + } fcc_challenge = XMM7360_RPC_MSG_ARG_GET_INT (arg); checksum = g_checksum_new (G_CHECKSUM_SHA256); @@ -566,7 +570,12 @@ fcc_lock_query_ready (MMBroadbandModem *self, /* second argument is fcc_state */ arg = (Xmm7360RpcMsgArg *) g_ptr_array_index (response->content, 1); - g_assert (arg->type == XMM7360_RPC_MSG_ARG_TYPE_LONG); + if (arg->type != XMM7360_RPC_MSG_ARG_TYPE_LONG) { + g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, + "Unexpected FCC check fcc_state type"); + g_object_unref (task); + return; + } if (XMM7360_RPC_MSG_ARG_GET_INT (arg)) { /* no FCC unlock required: FCC state is != 0 */ g_task_return_boolean (task, FALSE); @@ -576,7 +585,12 @@ fcc_lock_query_ready (MMBroadbandModem *self, /* third argument is fcc_mode */ arg = (Xmm7360RpcMsgArg *) g_ptr_array_index (response->content, 2); - g_assert (arg->type == XMM7360_RPC_MSG_ARG_TYPE_LONG); + if (arg->type != XMM7360_RPC_MSG_ARG_TYPE_LONG) { + g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, + "Unexpected FCC check fcc_mode type"); + g_object_unref (task); + return; + } if (!XMM7360_RPC_MSG_ARG_GET_INT (arg)) { /* no FCC unlock required: FCC mode is == 0 */ g_task_return_boolean (task, FALSE);