]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
validate tx power argument is a number
authorJohannes Berg <johannes.berg@intel.com>
Thu, 28 Apr 2011 17:41:04 +0000 (19:41 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 28 Apr 2011 17:41:04 +0000 (19:41 +0200)
phy.c

diff --git a/phy.c b/phy.c
index e3bd4e8bf54a64edb2d2a4c202c02bb014649541..91042b469fa72b04a01b5d9be06e77aa0cd94014 100644 (file)
--- a/phy.c
+++ b/phy.c
@@ -286,12 +286,15 @@ static int handle_txpower(struct nl80211_state *state,
        NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_TX_POWER_SETTING, type);
 
        if (type != NL80211_TX_POWER_AUTOMATIC) {
+               char *endptr;
                if (argc != 2) {
                        printf("Missing TX power level argument.\n");
                        return 2;
                }
 
-               mbm = atoi(argv[1]);
+               mbm = strtol(argv[1], &endptr, 10);
+               if (!*endptr)
+                       return 2;
                NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_TX_POWER_LEVEL, mbm);
        } else if (argc != 1)
                return 1;