提交 e6ff3f4e 编写于 作者: D Dan Carpenter 提交者: Greg Kroah-Hartman

staging: r8188eu: overflow in rtw_p2p_get_go_device_address()

The go_devadd_str[] array is two characters too small to hold the
address so we corrupt memory.

I've changed the user space API slightly and I don't have a way to test
if this breaks anything.  In the original code we truncated away the
last digit of the address and the NUL terminator so it was already a bit
broken.
Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
Acked-by: NLarry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 893134b0
...@@ -3164,9 +3164,7 @@ static int rtw_p2p_get_go_device_address(struct net_device *dev, ...@@ -3164,9 +3164,7 @@ static int rtw_p2p_get_go_device_address(struct net_device *dev,
u8 *p2pie; u8 *p2pie;
uint p2pielen = 0, attr_contentlen = 0; uint p2pielen = 0, attr_contentlen = 0;
u8 attr_content[100] = {0x00}; u8 attr_content[100] = {0x00};
u8 go_devadd_str[17 + 12] = {};
u8 go_devadd_str[17 + 10] = {0x00};
/* +10 is for the str "go_devadd =", we have to clear it at wrqu->data.pointer */
/* Commented by Albert 20121209 */ /* Commented by Albert 20121209 */
/* The input data is the GO's interface address which the application wants to know its device address. */ /* The input data is the GO's interface address which the application wants to know its device address. */
...@@ -3223,12 +3221,12 @@ static int rtw_p2p_get_go_device_address(struct net_device *dev, ...@@ -3223,12 +3221,12 @@ static int rtw_p2p_get_go_device_address(struct net_device *dev,
spin_unlock_bh(&pmlmepriv->scanned_queue.lock); spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
if (!blnMatch) if (!blnMatch)
sprintf(go_devadd_str, "\n\ndev_add = NULL"); snprintf(go_devadd_str, sizeof(go_devadd_str), "\n\ndev_add = NULL");
else else
sprintf(go_devadd_str, "\n\ndev_add =%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", snprintf(go_devadd_str, sizeof(go_devadd_str), "\n\ndev_add =%.2X:%.2X:%.2X:%.2X:%.2X:%.2X",
attr_content[0], attr_content[1], attr_content[2], attr_content[3], attr_content[4], attr_content[5]); attr_content[0], attr_content[1], attr_content[2], attr_content[3], attr_content[4], attr_content[5]);
if (copy_to_user(wrqu->data.pointer, go_devadd_str, 10 + 17)) if (copy_to_user(wrqu->data.pointer, go_devadd_str, sizeof(go_devadd_str)))
return -EFAULT; return -EFAULT;
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册