libiwinfo: fix integer overflow in dbm to mw conversion, also allow odd dbm numbers
authorJo-Philipp Wich <jow@openwrt.org>
Sat, 5 Feb 2011 18:20:48 +0000 (18:20 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sat, 5 Feb 2011 18:20:48 +0000 (18:20 +0000)
contrib/package/iwinfo/src/iwinfo.h
contrib/package/iwinfo/src/iwinfo_nl80211.c

index a9889bd9f7eb8e6093b48b5f5a75971687fa44bb..aa2f8335a19ea5a47b993e549ca73cb591b4fd5e 100644 (file)
@@ -64,8 +64,8 @@ struct iwinfo_assoclist_entry {
 };
 
 struct iwinfo_txpwrlist_entry {
-       uint8_t dbm;
-       uint8_t mw;
+       uint8_t  dbm;
+       uint16_t mw;
 };
 
 struct iwinfo_freqlist_entry {
index fa714e906393405f280e4c154d0fd9c5753c2bc2..0f57d37f1d15786ab603a42b520353d38510b46b 100644 (file)
@@ -1170,7 +1170,7 @@ int nl80211_get_txpwrlist(const char *ifname, char *buf, int *len)
        {
                for( dbm_cur = 0, dbm_cnt = 0;
                     dbm_cur < dbm_max;
-                    dbm_cur += 2, dbm_cnt++ )
+                    dbm_cur++, dbm_cnt++ )
                {
                        entry.dbm = dbm_cur;
                        entry.mw  = iwinfo_dbm2mw(dbm_cur);