aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2014-02-03 17:38:35 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-02-07 14:10:08 -0500
commite6ff3f4e6d258021fe041d7acf5d013c26bf387b (patch)
tree875c3aec92b193722c89cf0494956b947bc159cb
parent893134b084e137b92476ec11ce90790b5f568bb9 (diff)
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: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Larry Finger <Larry.Finger@lwfinger.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/rtl8188eu/os_dep/ioctl_linux.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
index 684bc8107a48..4ad80ae1067f 100644
--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -3164,9 +3164,7 @@ static int rtw_p2p_get_go_device_address(struct net_device *dev,
3164 u8 *p2pie; 3164 u8 *p2pie;
3165 uint p2pielen = 0, attr_contentlen = 0; 3165 uint p2pielen = 0, attr_contentlen = 0;
3166 u8 attr_content[100] = {0x00}; 3166 u8 attr_content[100] = {0x00};
3167 3167 u8 go_devadd_str[17 + 12] = {};
3168 u8 go_devadd_str[17 + 10] = {0x00};
3169 /* +10 is for the str "go_devadd =", we have to clear it at wrqu->data.pointer */
3170 3168
3171 /* Commented by Albert 20121209 */ 3169 /* Commented by Albert 20121209 */
3172 /* The input data is the GO's interface address which the application wants to know its device address. */ 3170 /* 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 spin_unlock_bh(&pmlmepriv->scanned_queue.lock); 3221 spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
3224 3222
3225 if (!blnMatch) 3223 if (!blnMatch)
3226 sprintf(go_devadd_str, "\n\ndev_add = NULL"); 3224 snprintf(go_devadd_str, sizeof(go_devadd_str), "\n\ndev_add = NULL");
3227 else 3225 else
3228 sprintf(go_devadd_str, "\n\ndev_add =%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", 3226 snprintf(go_devadd_str, sizeof(go_devadd_str), "\n\ndev_add =%.2X:%.2X:%.2X:%.2X:%.2X:%.2X",
3229 attr_content[0], attr_content[1], attr_content[2], attr_content[3], attr_content[4], attr_content[5]); 3227 attr_content[0], attr_content[1], attr_content[2], attr_content[3], attr_content[4], attr_content[5]);
3230 3228
3231 if (copy_to_user(wrqu->data.pointer, go_devadd_str, 10 + 17)) 3229 if (copy_to_user(wrqu->data.pointer, go_devadd_str, sizeof(go_devadd_str)))
3232 return -EFAULT; 3230 return -EFAULT;
3233 return ret; 3231 return ret;
3234} 3232}