David Heine - 2008-11-07

I get a segmentation fault when I use WPA with wlassistant.  I tracked it down to an unchecked call to readlink() at src/watools.cpp:232.  In my case, I'm using the wext driver so returning an empty string works.   The attached patch works around the seg fault.

--- orig_src/watools.cpp        2008-11-06 22:56:55.000000000 -0800
+++ src/watools.cpp     2008-11-06 22:55:55.000000000 -0800
@@ -229,7 +229,8 @@
        char* p;
        sprintf( origPath, "/sys/class/net/%s/device/driver", _ifname );
        memset( &symPath, 0, sizeof(symPath) );
-       readlink( (const char*)origPath, symPath, sizeof(symPath) );
+       if (readlink( (const char*)origPath, symPath, sizeof(symPath) ) == -1)
+         return "";
        p = strtok( symPath, "/" );
        do {
                strcpy( module, p );