[PATCH] staging: vt6656: Use proper target pointer in memcpy()

Tobias Klauser tklauser at distanz.ch
Fri Apr 25 09:53:58 UTC 2014


The coverity scanner marked these two memcpy()'s as causing a buffer
overflow in CIDs 142743 and 142744. This is due the h_dest member of
struct ethhdr being used as a target (size ETH_ALEN) in memcpy, but the
copy is of size ETH_HLEN. However, the intention here seems to be to
copy the entire ethernet header. Make that clear by specifying the
proper destination buffer.

Also remove the unnecessary casts of the source argument.

Signed-off-by: Tobias Klauser <tklauser at distanz.ch>
---
 drivers/staging/vt6656/rxtx.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 1ff1446..19a8741 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -2186,7 +2186,7 @@ int nsDMA_tx_packet(struct vnt_private *pDevice,
         return STATUS_RESOURCES;
     }
 
-    memcpy(pDevice->sTxEthHeader.h_dest, (u8 *)(skb->data), ETH_HLEN);
+	memcpy(&pDevice->sTxEthHeader, skb->data, ETH_HLEN);
 
 //mike add:station mode check eapol-key challenge--->
 {
@@ -2509,7 +2509,7 @@ int bRelayPacketSend(struct vnt_private *pDevice, u8 *pbySkbData, u32 uDataLen,
         return false;
     }
 
-    memcpy(pDevice->sTxEthHeader.h_dest, (u8 *)pbySkbData, ETH_HLEN);
+	memcpy(&pDevice->sTxEthHeader, pbySkbData, ETH_HLEN);
 
     if (pDevice->bEncryptionEnable == true) {
         bNeedEncryption = true;
-- 
1.7.9.5




More information about the devel mailing list