raster pushed a commit to branch master.


commit 90a4ad88b7fa6372f209e700b4cf962d96f8ea6b
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
Date:   Wed Apr 13 20:28:27 2016 +0900

    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.
 src/modules/wireless/connman.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/modules/wireless/connman.c b/src/modules/wireless/connman.c
index c41a00d..6beb24a 100644
--- a/src/modules/wireless/connman.c
+++ b/src/modules/wireless/connman.c
@@ -251,8 +251,12 @@ _connman_service_convert(Connman_Service *cs)
    Wireless_Network *wn;
    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->type = cs->type;
+   wn->strength = cs->strength;
    wn->connect_cb = _connman_service_connect;
    return wn;


Reply via email to