From: Johannes Berg Date: Thu, 28 Apr 2011 17:41:04 +0000 (+0200) Subject: validate tx power argument is a number X-Git-Tag: v3.0~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18e05613cd050d4d72938f1a140b2cd20864290f;p=thirdparty%2Fiw.git validate tx power argument is a number --- diff --git a/phy.c b/phy.c index e3bd4e8..91042b4 100644 --- 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;