diff mbox

P2P: Validate the freq in p2p_group_add

Message ID 1375870125-27991-8-git-send-email-ilan.peer@intel.com
State Accepted
Commit d393de1d27afe42d69d0a2461e489715f28c10ee
Headers show

Commit Message

Ilan Peer Aug. 7, 2013, 10:08 a.m. UTC
Add additional input verification for the frequency parameter
in p2p_group_add. Without this verification invalid freq could be
set an not handled properly.

Signed-hostap: Ilan Peer <ilan.peer@intel.com>
---
 src/p2p/p2p_utils.c |    9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Jouni Malinen Aug. 25, 2013, 8:30 a.m. UTC | #1
On Wed, Aug 07, 2013 at 01:08:44PM +0300, Ilan Peer wrote:
> Add additional input verification for the frequency parameter
> in p2p_group_add. Without this verification invalid freq could be
> set an not handled properly.

Thanks, applied.
diff mbox

Patch

diff --git a/src/p2p/p2p_utils.c b/src/p2p/p2p_utils.c
index 0da2682..deb7aa9 100644
--- a/src/p2p/p2p_utils.c
+++ b/src/p2p/p2p_utils.c
@@ -109,6 +109,9 @@  int p2p_freq_to_channel(unsigned int freq, u8 *op_class, u8 *channel)
 {
 	/* TODO: more operating classes */
 	if (freq >= 2412 && freq <= 2472) {
+		if ((freq - 2407) % 5)
+			return -1;
+
 		*op_class = 81; /* 2.407 GHz, channels 1..13 */
 		*channel = (freq - 2407) / 5;
 		return 0;
@@ -121,12 +124,18 @@  int p2p_freq_to_channel(unsigned int freq, u8 *op_class, u8 *channel)
 	}
 
 	if (freq >= 5180 && freq <= 5240) {
+		if ((freq - 5000) % 5)
+			return -1;
+
 		*op_class = 115; /* 5 GHz, channels 36..48 */
 		*channel = (freq - 5000) / 5;
 		return 0;
 	}
 
 	if (freq >= 5745 && freq <= 5805) {
+		if ((freq - 5000) % 5)
+			return -1;
+
 		*op_class = 124; /* 5 GHz, channels 149..161 */
 		*channel = (freq - 5000) / 5;
 		return 0;