iwinfo: fix integer overflow in assoclist rate reporting (#11073)
authorJo-Philipp Wich <jow@openwrt.org>
Mon, 5 Mar 2012 17:52:46 +0000 (17:52 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Mon, 5 Mar 2012 17:52:46 +0000 (17:52 +0000)
SVN-Revision: 30825

package/iwinfo/Makefile
package/iwinfo/src/include/iwinfo.h
package/iwinfo/src/iwinfo_cli.c

index f74fe2f1f9bcd88806c542f5e17a688380ee50bc..db8a3da25f35b6465da22456ba3ef440a9a58831 100644 (file)
@@ -7,7 +7,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=libiwinfo
-PKG_RELEASE:=31
+PKG_RELEASE:=32
 
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 PKG_CONFIG_DEPENDS := \
index 9e78bab70efc52f9e2aaf8b72514ed0590dbe3ad..868c10b3599216efb41a243d85370a6cac0dacda 100644 (file)
@@ -61,7 +61,7 @@ extern const char *IWINFO_OPMODE_NAMES[];
 
 
 struct iwinfo_rate_entry {
-       uint16_t rate;
+       uint32_t rate;
        int8_t mcs;
        uint8_t is_40mhz:1;
        uint8_t is_short_gi:1;
index 0fdb21ec677c2f6977597b9962db620ef7ac0ec8..7ec5aef95c8f485283ff8af7e04780917c62acf8 100644 (file)
@@ -134,7 +134,8 @@ static char * format_rate(int rate)
        if (rate <= 0)
                snprintf(buf, sizeof(buf), "unknown");
        else
-               snprintf(buf, sizeof(buf), "%.1f MBit/s", ((float)rate / 1000.0));
+               snprintf(buf, sizeof(buf), "%d.%d MBit/s",
+                       rate / 1000, (rate % 1000) / 100);
 
        return buf;
 }