Add a pointer check to ipc_net_plmn_sel
authorAlexander Tarasikov <alexander.tarasikov@gmail.com>
Wed, 22 Aug 2012 21:30:06 +0000 (01:30 +0400)
committerAlexander Tarasikov <alexander.tarasikov@gmail.com>
Wed, 22 Aug 2012 21:30:06 +0000 (01:30 +0400)
net.c

diff --git a/net.c b/net.c
index 83ea129..24b27e3 100644 (file)
--- a/net.c
+++ b/net.c
@@ -795,10 +795,19 @@ void ril_request_query_network_selection_mode(RIL_Token t)
 
 void ipc_net_plmn_sel(struct ipc_message_info *info)
 {
-       struct ipc_net_plmn_sel_get *plmn_sel = (struct ipc_net_plmn_sel_get *) info->data;
-       int ril_mode = ipc2ril_plmn_sel(plmn_sel->plmn_sel);
+       struct ipc_net_plmn_sel_get *plmn_sel;
+       int ril_mode;
 
-       RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_SUCCESS, &ril_mode, sizeof(int));
+       if (!info)
+               return;
+       
+       if (!info->data || info->length < sizeof(struct ipc_net_plmn_sel_get))
+               return;
+       
+       plmn_sel = (struct ipc_net_plmn_sel_get *) info->data;
+       ril_mode = ipc2ril_plmn_sel(plmn_sel->plmn_sel);
+       RIL_onRequestComplete(reqGetToken(info->aseq),
+               RIL_E_SUCCESS, &ril_mode, sizeof(int));
 }
 
 void ipc_net_plmn_sel_complete(struct ipc_message_info *info)