From: Dan Carpenter <hidden> Date: 2013-09-25 08:57:30
If "resp_len" gets set to negative then it counts as a high positive
value.
Signed-off-by: Dan Carpenter <redacted>
---
I spotted this reviewing the int => bool changes, but I don't have the
hardware and can't test it.
If "resp_len" gets set to negative then it counts as a high positive value.
Signed-off-by: Dan Carpenter <redacted>
---
I spotted this reviewing the int => bool changes, but I don't have the
hardware and can't test it.
Thanks for spotting this potential integer underflow problem.
I think we can change the 'resp_len' variable type to a signed integer to fix this issue.
Thanks,
Bing
quoted hunk
diff --git a/drivers/net/wireless/mwifiex/wmm.c
b/drivers/net/wireless/mwifiex/wmm.c
index 2e8f9cd..3c6ee3a 100644
From: Dan Carpenter <hidden> Date: 2013-09-25 18:23:59
On Wed, Sep 25, 2013 at 09:25:46AM -0700, Bing Zhao wrote:
Hi Dan,
quoted
If "resp_len" gets set to negative then it counts as a high positive value.
Signed-off-by: Dan Carpenter <redacted>
---
I spotted this reviewing the int => bool changes, but I don't have the
hardware and can't test it.
Thanks for spotting this potential integer underflow problem.
I think we can change the 'resp_len' variable type to a signed integer
to fix this issue.
No, that doesn't work because the comparison against sizeof() get's
promoted to size_t. In other words, negative values still count as
large positive values.
regards,
dan carpenter
I think we can change the 'resp_len' variable type to a signed integer
to fix this issue.
No, that doesn't work because the comparison against sizeof() get's
promoted to size_t. In other words, negative values still count as
large positive values.
You are right. The negative value counts as a large positive number while comparing against sizeof().
I can add a "const int hdr_size" variable to store the value of sizeof(...) and compare resp_len to hdr_size. The "sizeof(...)" has been used multiple times in this function, so I think it's worth adding a variable for it.
No, that doesn't work because the comparison against sizeof() get's
promoted to size_t. In other words, negative values still count as
large positive values.
You are right. The negative value counts as a large positive number while comparing against sizeof().
I can add a "const int hdr_size" variable to store the value of sizeof(...) and compare resp_len to
hdr_size. The "sizeof(...)" has been used multiple times in this function, so I think it's worth
adding a variable for it.
Well, there is another problem here.
We might have accessed invalid memory while handling switch case in last iteration, because we didn't count tlv_len in "while(...)" condition check.
To fix this, Dan's change makes sense. But we should check the length before accessing the buffer.
From: Dan Carpenter <hidden> Date: 2013-09-26 21:07:03
There are several other similar functions as well. For example, the
while loops in mwifiex_ret_tx_rate_cfg() and mwifiex_get_power_level().
regards,
dan carpenter
From: John W. Linville <hidden> Date: 2013-10-10 17:26:33
On Thu, Sep 26, 2013 at 02:57:21PM -0700, Bing Zhao wrote:
Hi Dan,
quoted
There are several other similar functions as well. For example, the
while loops in mwifiex_ret_tx_rate_cfg() and mwifiex_get_power_level().
Thanks for pointing it out. We will have them fixed.
Regards,
Bing
OK, I'm confused by this thread...I'm dropping it.
Dan & Bing,
Please repost as a series of patches that I don't have to piece
together from a series of replies...
John
--
John W. Linville Someday the world will need a hero, and you
linville@tuxdriver.com might be all we have. Be ready.