aidl: Change the way of convert string to integer link_id
hostapd_get_iface_by_link_id() need get correct link_id to check if
the hostapd_iface had added. Forcing the string link_id to an integer
type will result in the wrong link_id number causing hostapd to crash.
Change the way to convert string to integer link_id to get correct
link_id.
Bug: 340821197
Test: Start MLO SAP from UI.
Change-Id: I6a13a5d1837ae8565cccd08e6ce31c9f276b672f
diff --git a/hostapd/aidl/hostapd.cpp b/hostapd/aidl/hostapd.cpp
index 441ecef..eac2191 100644
--- a/hostapd/aidl/hostapd.cpp
+++ b/hostapd/aidl/hostapd.cpp
@@ -1308,7 +1308,7 @@
const std::string owe_transition_ifname)
{
if (iface_params.usesMlo) { // the mlo case, iface name is instance name which is mld_link_id
- if (hostapd_get_iface_by_link_id(interfaces_, (size_t) iface_params.name.c_str())) {
+ if (hostapd_get_iface_by_link_id(interfaces_, std::stoi(iface_params.name.c_str()))) {
wpa_printf(
MSG_ERROR, "Instance link id %s already present",
iface_params.name.c_str());
@@ -1348,7 +1348,7 @@
// find the iface and set up callback.
struct hostapd_data* iface_hapd = iface_params.usesMlo ?
- hostapd_get_iface_by_link_id(interfaces_, (size_t) iface_params.name.c_str()) :
+ hostapd_get_iface_by_link_id(interfaces_, std::stoi(iface_params.name.c_str())) :
hostapd_get_iface(interfaces_, iface_params.name.c_str());
WPA_ASSERT(iface_hapd != nullptr && iface_hapd->iface != nullptr);
if (iface_params.usesMlo) {
@@ -1609,7 +1609,7 @@
return createStatus(HostapdStatusCode::FAILURE_IFACE_UNKNOWN);
}
struct hostapd_data* iface_hapd =
- hostapd_get_iface_by_link_id(interfaces_, (size_t) linkIdentity.c_str());
+ hostapd_get_iface_by_link_id(interfaces_, std::stoi(linkIdentity.c_str()));
if (iface_hapd) {
// Currently, hostapd_link_remove is still under CONFIG_TESTING_OPTIONS.
// TODO: b/340821197 - Make sure to take out the hostapd_link_remove() and other related code