IPACM: Fix the KW errors
This change fixes the KW errors. strncpy() API
is changed to strlcpy(). String should be null
terminated to avoid buffer overflow.
Change-Id: I7660707dbb535b1fbbf127ad3bb2a8b614667401
diff --git a/ipacm/src/IPACM_Lan.cpp b/ipacm/src/IPACM_Lan.cpp
index a768e08..9b47008 100644
--- a/ipacm/src/IPACM_Lan.cpp
+++ b/ipacm/src/IPACM_Lan.cpp
@@ -1648,7 +1648,7 @@
snprintf(index,sizeof(index), "%d", ipa_if_num);
strlcpy(pHeaderDescriptor->hdr[0].name, index, sizeof(pHeaderDescriptor->hdr[0].name));
-
+ pHeaderDescriptor->hdr[0].name[IPA_RESOURCE_NAME_MAX-1] = '\0';
if (strlcat(pHeaderDescriptor->hdr[0].name, IPA_ETH_HDR_NAME_v4, sizeof(pHeaderDescriptor->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)
{
IPACMERR(" header name construction failed exceed length (%d)\n", strlen(pHeaderDescriptor->hdr[0].name));
@@ -1739,7 +1739,7 @@
snprintf(index,sizeof(index), "%d", ipa_if_num);
strlcpy(pHeaderDescriptor->hdr[0].name, index, sizeof(pHeaderDescriptor->hdr[0].name));
-
+ pHeaderDescriptor->hdr[0].name[IPA_RESOURCE_NAME_MAX-1] = '\0';
if (strlcat(pHeaderDescriptor->hdr[0].name, IPA_ETH_HDR_NAME_v6, sizeof(pHeaderDescriptor->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)
{
IPACMERR(" header name construction failed exceed length (%d)\n", strlen(pHeaderDescriptor->hdr[0].name));
@@ -1984,11 +1984,10 @@
IPACMDBG_H("client(%d): v4 header handle:(0x%x)\n",
eth_index,
get_client_memptr(eth_client, eth_index)->hdr_hdl_v4);
- strncpy(rt_rule->rt_tbl_name,
+ strlcpy(rt_rule->rt_tbl_name,
IPACM_Iface::ipacmcfg->rt_tbl_lan_v4.name,
sizeof(rt_rule->rt_tbl_name));
-
-
+ rt_rule->rt_tbl_name[IPA_RESOURCE_NAME_MAX-1] = '\0';
rt_rule_entry->rule.dst = tx_prop->tx[tx_index].dst_pipe;
memcpy(&rt_rule_entry->rule.attrib,
&tx_prop->tx[tx_index].attrib,
@@ -2020,10 +2019,10 @@
get_client_memptr(eth_client, eth_index)->hdr_hdl_v6);
/* v6 LAN_RT_TBL */
- strncpy(rt_rule->rt_tbl_name,
+ strlcpy(rt_rule->rt_tbl_name,
IPACM_Iface::ipacmcfg->rt_tbl_v6.name,
sizeof(rt_rule->rt_tbl_name));
-
+ rt_rule->rt_tbl_name[IPA_RESOURCE_NAME_MAX-1] = '\0';
/* Support QCMAP LAN traffic feature, send to A5 */
rt_rule_entry->rule.dst = IPA_CLIENT_APPS_LAN_CONS;
memset(&rt_rule_entry->rule.attrib, 0, sizeof(rt_rule_entry->rule.attrib));
@@ -2050,8 +2049,8 @@
get_client_memptr(eth_client, eth_index)->eth_rt_hdl[tx_index].eth_rt_rule_hdl_v6[v6_num], iptype);
/*Copy same rule to v6 WAN RT TBL*/
- strncpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_wan_v6.name, sizeof(rt_rule->rt_tbl_name));
-
+ strlcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_wan_v6.name, sizeof(rt_rule->rt_tbl_name));
+ rt_rule->rt_tbl_name[IPA_RESOURCE_NAME_MAX-1] = '\0';
/* Downlink traffic from Wan iface, directly through IPA */
rt_rule_entry->rule.dst = tx_prop->tx[tx_index].dst_pipe;
memcpy(&rt_rule_entry->rule.attrib,
@@ -3890,7 +3889,7 @@
memset(pHeader->hdr[0].name, 0, sizeof(pHeader->hdr[0].name));
strlcpy(pHeader->hdr[0].name, IPA_LAN_TO_LAN_USB_HDR_NAME_V4, sizeof(pHeader->hdr[0].name));
-
+ pHeader->hdr[0].name[IPA_RESOURCE_NAME_MAX-1] = '\0';
for(j=0; j<MAX_OFFLOAD_PAIR; j++)
{
if( lan2lan_hdr_hdl_v4[j].valid == false)
@@ -3977,7 +3976,7 @@
memset(pHeader->hdr[0].name, 0, sizeof(pHeader->hdr[0].name));
strlcpy(pHeader->hdr[0].name, IPA_LAN_TO_LAN_USB_HDR_NAME_V6, sizeof(pHeader->hdr[0].name));
-
+ pHeader->hdr[0].name[IPA_RESOURCE_NAME_MAX-1] = '\0';
for(j=0; j<MAX_OFFLOAD_PAIR; j++)
{
if( lan2lan_hdr_hdl_v6[j].valid == false)
@@ -6129,25 +6128,25 @@
{
if (iptype == IPA_IP_v4)
{
- strncpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_lan_v4.name, sizeof(rt_rule_table->rt_tbl_name));
+ strlcpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_lan_v4.name, sizeof(rt_rule_table->rt_tbl_name));
}
else
{
- strncpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_lan_v6.name, sizeof(rt_rule_table->rt_tbl_name));
+ strlcpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_lan_v6.name, sizeof(rt_rule_table->rt_tbl_name));
}
}
else
{
if (iptype == IPA_IP_v4)
{
- strncpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_wlan_v4.name, sizeof(rt_rule_table->rt_tbl_name));
+ strlcpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_wlan_v4.name, sizeof(rt_rule_table->rt_tbl_name));
}
else
{
- strncpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_wlan_v6.name, sizeof(rt_rule_table->rt_tbl_name));
+ strlcpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_wlan_v6.name, sizeof(rt_rule_table->rt_tbl_name));
}
}
-
+ rt_rule_table->rt_tbl_name[IPA_RESOURCE_NAME_MAX-1] = '\0';
memset(&rt_rule, 0, sizeof(ipa_rt_rule_add));
rt_rule.at_rear = false;
rt_rule.status = -1;
diff --git a/ipacm/src/IPACM_Wan.cpp b/ipacm/src/IPACM_Wan.cpp
index 154c8dc..06080a0 100644
--- a/ipacm/src/IPACM_Wan.cpp
+++ b/ipacm/src/IPACM_Wan.cpp
@@ -230,7 +230,8 @@
rt_rule_entry = &rt_rule->rules[0];
if(m_is_sta_mode == Q6_WAN)
{
- strncpy(hdr.name, tx_prop->tx[0].hdr_name, sizeof(hdr.name));
+ strlcpy(hdr.name, tx_prop->tx[0].hdr_name, sizeof(hdr.name));
+ hdr.name[IPA_RESOURCE_NAME_MAX-1] = '\0';
if(m_header.GetHeaderHandle(&hdr) == false)
{
IPACMERR("Failed to get QMAP header.\n");
@@ -415,7 +416,8 @@
rt_rule_entry = &rt_rule->rules[0];
if(m_is_sta_mode == Q6_WAN)
{
- strncpy(hdr.name, tx_prop->tx[0].hdr_name, sizeof(hdr.name));
+ strlcpy(hdr.name, tx_prop->tx[0].hdr_name, sizeof(hdr.name));
+ hdr.name[IPA_RESOURCE_NAME_MAX-1] = '\0';
if(m_header.GetHeaderHandle(&hdr) == false)
{
IPACMERR("Failed to get QMAP header.\n");
@@ -1353,7 +1355,8 @@
if(m_is_sta_mode == Q6_WAN)
{
memset(&hdr, 0, sizeof(hdr));
- strncpy(hdr.name, tx_prop->tx[0].hdr_name, sizeof(hdr.name));
+ strlcpy(hdr.name, tx_prop->tx[0].hdr_name, sizeof(hdr.name));
+ hdr.name[IPA_RESOURCE_NAME_MAX-1] = '\0';
if(m_header.GetHeaderHandle(&hdr) == false)
{
IPACMERR("Failed to get QMAP header.\n");
@@ -1609,7 +1612,7 @@
/* default firewall is disable and the rule action is drop */
memset(&firewall_config, 0, sizeof(firewall_config));
- strncpy(firewall_config.firewall_config_file, "/etc/mobileap_firewall.xml", sizeof(firewall_config.firewall_config_file));
+ strlcpy(firewall_config.firewall_config_file, "/etc/mobileap_firewall.xml", sizeof(firewall_config.firewall_config_file));
if (firewall_config.firewall_config_file)
{
@@ -2317,7 +2320,7 @@
/* default firewall is disable and the rule action is drop */
memset(&firewall_config, 0, sizeof(firewall_config));
- strncpy(firewall_config.firewall_config_file, "/etc/mobileap_firewall.xml", sizeof(firewall_config.firewall_config_file));
+ strlcpy(firewall_config.firewall_config_file, "/etc/mobileap_firewall.xml", sizeof(firewall_config.firewall_config_file));
if (firewall_config.firewall_config_file)
{
@@ -2355,7 +2358,8 @@
memset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx));
rt_tbl_idx.ip = IPA_IP_v6;
- strncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);
+ strlcpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);
+ rt_tbl_idx.name[IPA_RESOURCE_NAME_MAX-1] = '\0';
if(0 != ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx))
{
IPACMERR("Failed to get routing table index from name\n");
@@ -2422,13 +2426,13 @@
rt_tbl_idx.ip = iptype;
if(flt_rule_entry.rule.action == IPA_PASS_TO_ROUTING)
{
- strncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);
+ strlcpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);
}
else /*pass to dst nat*/
{
- strncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_lan_v4.name, IPA_RESOURCE_NAME_MAX);
+ strlcpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_lan_v4.name, IPA_RESOURCE_NAME_MAX);
}
-
+ rt_tbl_idx.name[IPA_RESOURCE_NAME_MAX-1] = '\0';
if(0 != ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx))
{
IPACMERR("Failed to get routing table index from name\n");
@@ -2558,12 +2562,13 @@
if(flt_rule_entry.rule.action == IPA_PASS_TO_ROUTING)
{
- strncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);
+ strlcpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);
}
else /*pass to dst nat*/
{
- strncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_lan_v4.name, IPA_RESOURCE_NAME_MAX);
+ strlcpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_lan_v4.name, IPA_RESOURCE_NAME_MAX);
}
+ rt_tbl_idx.name[IPA_RESOURCE_NAME_MAX-1] = '\0';
if(0 != ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx))
{
@@ -2631,12 +2636,14 @@
/* matched rules for v6 go PASS_TO_ROUTE */
if(firewall_config.rule_action_accept == true)
{
- strncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_v6.name, IPA_RESOURCE_NAME_MAX);
+ strlcpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_v6.name, IPA_RESOURCE_NAME_MAX);
}
else
{
- strncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);
+ strlcpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);
}
+ rt_tbl_idx.name[IPA_RESOURCE_NAME_MAX-1] = '\0';
+
if(0 != ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx))
{
IPACMERR("Failed to get routing table index from name\n");
@@ -2742,17 +2749,18 @@
/* default action for v6 is PASS_TO_ROUTE unless user set to exception*/
if(firewall_config.rule_action_accept == true)
{
- strncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);
+ strlcpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);
}
else
{
- strncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_v6.name, IPA_RESOURCE_NAME_MAX);
+ strlcpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_v6.name, IPA_RESOURCE_NAME_MAX);
}
}
else
{
- strncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_v6.name, IPA_RESOURCE_NAME_MAX);
+ strlcpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_v6.name, IPA_RESOURCE_NAME_MAX);
}
+ rt_tbl_idx.name[IPA_RESOURCE_NAME_MAX-1] = '\0';
if(0 != ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx))
{
IPACMERR("Failed to get routing table index from name\n");
@@ -2899,7 +2907,8 @@
original_num_rules = IPACM_Wan::num_v4_flt_rule;
memset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx));
- strncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);
+ strlcpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);
+ rt_tbl_idx.name[IPA_RESOURCE_NAME_MAX-1] = '\0';
rt_tbl_idx.ip = iptype;
if(0 != ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx))
{
@@ -3015,7 +3024,8 @@
original_num_rules = IPACM_Wan::num_v6_flt_rule;
memset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx));
- strncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);
+ strlcpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);
+ rt_tbl_idx.name[IPA_RESOURCE_NAME_MAX-1] = '\0';
rt_tbl_idx.ip = iptype;
if(0 != ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx))
{
@@ -3204,7 +3214,8 @@
if (iptype == IPA_IP_v4)
{
memset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx));
- strncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);
+ strlcpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);
+ rt_tbl_idx.name[IPA_RESOURCE_NAME_MAX-1] = '\0';
rt_tbl_idx.ip = iptype;
if(0 != ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx))
{
@@ -3283,7 +3294,8 @@
else /*insert rules for ipv6*/
{
memset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx));
- strncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);
+ strlcpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);
+ rt_tbl_idx.name[IPA_RESOURCE_NAME_MAX-1] = '\0';
rt_tbl_idx.ip = iptype;
if(0 != ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx))
{
@@ -3837,7 +3849,8 @@
/* get eMBMS ODU tbl index*/
memset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx));
- strncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_odu_v4.name, IPA_RESOURCE_NAME_MAX);
+ strlcpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_odu_v4.name, IPA_RESOURCE_NAME_MAX);
+ rt_tbl_idx.name[IPA_RESOURCE_NAME_MAX-1] = '\0';
rt_tbl_idx.ip = IPA_IP_v4;
if(0 != ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx))
{
@@ -3882,7 +3895,8 @@
memset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));
/* get eMBMS ODU tbl*/
memset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx));
- strncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_odu_v6.name, IPA_RESOURCE_NAME_MAX);
+ strlcpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_odu_v6.name, IPA_RESOURCE_NAME_MAX);
+ rt_tbl_idx.name[IPA_RESOURCE_NAME_MAX-1] = '\0';
rt_tbl_idx.ip = IPA_IP_v6;
if(0 != ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx))
{
@@ -4397,7 +4411,8 @@
/* Configuring Software-Routing Filtering Rule */
memset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));
memset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx));
- strncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);
+ strlcpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);
+ rt_tbl_idx.name[IPA_RESOURCE_NAME_MAX-1] = '\0';
rt_tbl_idx.ip = IPA_IP_v4;
if(ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx) < 0)
{
@@ -4454,7 +4469,8 @@
/* Configuring Software-Routing Filtering Rule */
memset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));
memset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx));
- strncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);
+ strlcpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);
+ rt_tbl_idx.name[IPA_RESOURCE_NAME_MAX-1] = '\0';
rt_tbl_idx.ip = IPA_IP_v6;
if(ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx) < 0)
{
@@ -4777,7 +4793,7 @@
snprintf(index,sizeof(index), "%d", ipa_if_num);
strlcpy(pHeaderDescriptor->hdr[0].name, index, sizeof(pHeaderDescriptor->hdr[0].name));
-
+ pHeaderDescriptor->hdr[0].name[IPA_RESOURCE_NAME_MAX-1] = '\0';
if (strlcat(pHeaderDescriptor->hdr[0].name, IPA_WAN_PARTIAL_HDR_NAME_v4, sizeof(pHeaderDescriptor->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)
{
IPACMERR(" header name construction failed exceed length (%d)\n", strlen(pHeaderDescriptor->hdr[0].name));
@@ -4874,7 +4890,7 @@
snprintf(index,sizeof(index), "%d", ipa_if_num);
strlcpy(pHeaderDescriptor->hdr[0].name, index, sizeof(pHeaderDescriptor->hdr[0].name));
-
+ pHeaderDescriptor->hdr[0].name[IPA_RESOURCE_NAME_MAX-1] = '\0';
if (strlcat(pHeaderDescriptor->hdr[0].name, IPA_WAN_PARTIAL_HDR_NAME_v6, sizeof(pHeaderDescriptor->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)
{
IPACMERR(" header name construction failed exceed length (%d)\n", strlen(pHeaderDescriptor->hdr[0].name));
@@ -5120,10 +5136,10 @@
IPACMDBG_H("client(%d): v4 header handle:(0x%x)\n",
wan_index,
get_client_memptr(wan_client, wan_index)->hdr_hdl_v4);
- strncpy(rt_rule->rt_tbl_name,
+ strlcpy(rt_rule->rt_tbl_name,
IPACM_Iface::ipacmcfg->rt_tbl_wan_v4.name,
sizeof(rt_rule->rt_tbl_name));
-
+ rt_rule->rt_tbl_name[IPA_RESOURCE_NAME_MAX-1] = '\0';
if (IPACM_Iface::ipacmcfg->isMCC_Mode == true)
{
IPACMDBG_H("In MCC mode, use alt dst pipe: %d\n",
@@ -5163,10 +5179,10 @@
get_client_memptr(wan_client, wan_index)->hdr_hdl_v6);
/* v6 LAN_RT_TBL */
- strncpy(rt_rule->rt_tbl_name,
+ strlcpy(rt_rule->rt_tbl_name,
IPACM_Iface::ipacmcfg->rt_tbl_v6.name,
sizeof(rt_rule->rt_tbl_name));
-
+ rt_rule->rt_tbl_name[IPA_RESOURCE_NAME_MAX-1] = '\0';
/* Support QCMAP LAN traffic feature, send to A5 */
rt_rule_entry->rule.dst = iface_query->excp_pipe;
memset(&rt_rule_entry->rule.attrib, 0, sizeof(rt_rule_entry->rule.attrib));
@@ -5193,10 +5209,10 @@
get_client_memptr(wan_client, wan_index)->wan_rt_hdl[tx_index].wan_rt_rule_hdl_v6[v6_num], iptype);
/*Copy same rule to v6 WAN RT TBL*/
- strncpy(rt_rule->rt_tbl_name,
+ strlcpy(rt_rule->rt_tbl_name,
IPACM_Iface::ipacmcfg->rt_tbl_wan_v6.name,
sizeof(rt_rule->rt_tbl_name));
-
+ rt_rule->rt_tbl_name[IPA_RESOURCE_NAME_MAX-1] = '\0';
/* Downlink traffic from Wan iface, directly through IPA */
if (IPACM_Iface::ipacmcfg->isMCC_Mode == true)
{
diff --git a/ipacm/src/IPACM_Wlan.cpp b/ipacm/src/IPACM_Wlan.cpp
index a1a103e..89c3b5e 100644
--- a/ipacm/src/IPACM_Wlan.cpp
+++ b/ipacm/src/IPACM_Wlan.cpp
@@ -1663,6 +1663,7 @@
snprintf(index,sizeof(index), "%d", ipa_if_num);
strlcpy(pHeaderDescriptor->hdr[0].name, index, sizeof(pHeaderDescriptor->hdr[0].name));
+ pHeaderDescriptor->hdr[0].name[IPA_RESOURCE_NAME_MAX-1] = '\0';
if (strlcat(pHeaderDescriptor->hdr[0].name, IPA_WLAN_PARTIAL_HDR_NAME_v4, sizeof(pHeaderDescriptor->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)
{
@@ -1768,6 +1769,7 @@
snprintf(index,sizeof(index), "%d", ipa_if_num);
strlcpy(pHeaderDescriptor->hdr[0].name, index, sizeof(pHeaderDescriptor->hdr[0].name));
+ pHeaderDescriptor->hdr[0].name[IPA_RESOURCE_NAME_MAX-1] = '\0';
if (strlcat(pHeaderDescriptor->hdr[0].name, IPA_WLAN_PARTIAL_HDR_NAME_v6, sizeof(pHeaderDescriptor->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)
{
IPACMERR(" header name construction failed exceed length (%d)\n", strlen(pHeaderDescriptor->hdr[0].name));
@@ -2019,10 +2021,10 @@
IPACMDBG_H("client(%d): v4 header handle:(0x%x)\n",
wlan_index,
get_client_memptr(wlan_client, wlan_index)->hdr_hdl_v4);
- strncpy(rt_rule->rt_tbl_name,
+ strlcpy(rt_rule->rt_tbl_name,
IPACM_Iface::ipacmcfg->rt_tbl_lan_v4.name,
sizeof(rt_rule->rt_tbl_name));
-
+ rt_rule->rt_tbl_name[IPA_RESOURCE_NAME_MAX-1] = '\0';
if(IPACM_Iface::ipacmcfg->isMCC_Mode)
{
@@ -2065,10 +2067,10 @@
get_client_memptr(wlan_client, wlan_index)->hdr_hdl_v6);
/* v6 LAN_RT_TBL */
- strncpy(rt_rule->rt_tbl_name,
+ strlcpy(rt_rule->rt_tbl_name,
IPACM_Iface::ipacmcfg->rt_tbl_v6.name,
sizeof(rt_rule->rt_tbl_name));
-
+ rt_rule->rt_tbl_name[IPA_RESOURCE_NAME_MAX-1] = '\0';
/* Support QCMAP LAN traffic feature, send to A5 */
rt_rule_entry->rule.dst = iface_query->excp_pipe;
memset(&rt_rule_entry->rule.attrib, 0, sizeof(rt_rule_entry->rule.attrib));
@@ -2095,10 +2097,10 @@
get_client_memptr(wlan_client, wlan_index)->wifi_rt_hdl[tx_index].wifi_rt_rule_hdl_v6[v6_num], iptype);
/*Copy same rule to v6 WAN RT TBL*/
- strncpy(rt_rule->rt_tbl_name,
+ strlcpy(rt_rule->rt_tbl_name,
IPACM_Iface::ipacmcfg->rt_tbl_wan_v6.name,
sizeof(rt_rule->rt_tbl_name));
-
+ rt_rule->rt_tbl_name[IPA_RESOURCE_NAME_MAX-1] = '\0';
/* Downlink traffic from Wan iface, directly through IPA */
if(IPACM_Iface::ipacmcfg->isMCC_Mode)
{
@@ -2915,7 +2917,7 @@
memset(pHeader->hdr[0].name, 0, sizeof(pHeader->hdr[0].name));
strlcpy(pHeader->hdr[0].name, IPA_LAN_TO_LAN_WLAN_HDR_NAME_V4, sizeof(pHeader->hdr[0].name));
-
+ pHeader->hdr[0].name[IPA_RESOURCE_NAME_MAX-1] = '\0';
for(j=0; j<MAX_OFFLOAD_PAIR; j++)
{
if( lan2lan_hdr_hdl_v4[j].valid == false)
@@ -3032,7 +3034,7 @@
memset(pHeader->hdr[0].name, 0, sizeof(pHeader->hdr[0].name));
strlcpy(pHeader->hdr[0].name, IPA_LAN_TO_LAN_WLAN_HDR_NAME_V6, sizeof(pHeader->hdr[0].name));
-
+ pHeader->hdr[0].name[IPA_RESOURCE_NAME_MAX-1] = '\0';
for(j=0; j<MAX_OFFLOAD_PAIR; j++)
{
@@ -4274,25 +4276,25 @@
{
if(iptype == IPA_IP_v4)
{
- strncpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_wlan_wlan_v4.name, sizeof(rt_rule_table->rt_tbl_name));
+ strlcpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_wlan_wlan_v4.name, sizeof(rt_rule_table->rt_tbl_name));
}
else
{
- strncpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_wlan_wlan_v6.name, sizeof(rt_rule_table->rt_tbl_name));
+ strlcpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_wlan_wlan_v6.name, sizeof(rt_rule_table->rt_tbl_name));
}
}
else
{
if(iptype == IPA_IP_v4)
{
- strncpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_wlan_v4.name, sizeof(rt_rule_table->rt_tbl_name));
+ strlcpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_wlan_v4.name, sizeof(rt_rule_table->rt_tbl_name));
}
else
{
- strncpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_wlan_v6.name, sizeof(rt_rule_table->rt_tbl_name));
+ strlcpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_wlan_v6.name, sizeof(rt_rule_table->rt_tbl_name));
}
}
-
+ rt_rule_table->rt_tbl_name[IPA_RESOURCE_NAME_MAX-1] = '\0';
memset(&rt_rule, 0, sizeof(ipa_rt_rule_add));
rt_rule.at_rear = false;
rt_rule.status = -1;