forked from enlightenment/enlightenment
e - wireless module - remove horrible memcpy with offsetof magic
while it technically wuld work, this memcpy here is fragile and the moment some struct members changed it'd fall apart and have fields all misaligned etc. in fact using offsetof means it might over-copy a bit extra due to alignment of the connect_cb vs method in Connman_Service. so manually aissgne the fields in the func instead to be far safer. if anything this should become a sub-struct with a type that can then be properly copied even if things change. @fix
This commit is contained in:
parent
119a0629f2
commit
90a4ad88b7
|
@ -251,8 +251,12 @@ _connman_service_convert(Connman_Service *cs)
|
||||||
Wireless_Network *wn;
|
Wireless_Network *wn;
|
||||||
|
|
||||||
wn = E_NEW(Wireless_Network, 1);
|
wn = E_NEW(Wireless_Network, 1);
|
||||||
memcpy(wn, &cs->path, offsetof(Wireless_Network, connect_cb));
|
wn->path = cs->path;
|
||||||
|
wn->name = cs->name;
|
||||||
|
wn->security = cs->security;
|
||||||
wn->state = _connman_wifi_state_convert(cs->state);
|
wn->state = _connman_wifi_state_convert(cs->state);
|
||||||
|
wn->type = cs->type;
|
||||||
|
wn->strength = cs->strength;
|
||||||
wn->connect_cb = _connman_service_connect;
|
wn->connect_cb = _connman_service_connect;
|
||||||
return wn;
|
return wn;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue