Staging: vt6655-6: shift wrap in hostap_set_encryption()
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 11 Oct 2012 06:55:25 +0000 (09:55 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 22 Oct 2012 20:26:40 +0000 (13:26 -0700)
abySeq is an unsigned char so shifting more than 31 bits will lead to a
shift wrapping bug.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vt6655/hostap.c
drivers/staging/vt6656/hostap.c

index 67b1b88b1b89d365a4cc8f75cba1d20f1318928a..5f13890cf1241af033949988b437b284b23c8a4c 100644 (file)
@@ -596,9 +596,9 @@ static int hostap_set_encryption(PSDevice pDevice,
 
        if (param->u.crypt.seq) {
            memcpy(&abySeq, param->u.crypt.seq, 8);
-               for (ii = 0 ; ii < 8 ; ii++) {
-                KeyRSC |= (abySeq[ii] << (ii * 8));
-               }
+               for (ii = 0 ; ii < 8 ; ii++)
+                       KeyRSC |= (unsigned long)abySeq[ii] << (ii * 8);
+
                dwKeyIndex |= 1 << 29;
                pMgmt->sNodeDBTable[iNodeIndex].KeyRSC = KeyRSC;
        }
index 0a73d4060ee19348122a1e036d2c604374f75d41..26a7d0e4b0487aa118d85e9e665238ccb6ade802 100644 (file)
@@ -542,9 +542,9 @@ static int hostap_set_encryption(PSDevice pDevice,
 
        if (param->u.crypt.seq) {
            memcpy(&abySeq, param->u.crypt.seq, 8);
-               for (ii = 0 ; ii < 8 ; ii++) {
-                KeyRSC |= (abySeq[ii] << (ii * 8));
-               }
+               for (ii = 0 ; ii < 8 ; ii++)
+                       KeyRSC |= (unsigned long)abySeq[ii] << (ii * 8);
+
                dwKeyIndex |= 1 << 29;
                pMgmt->sNodeDBTable[iNodeIndex].KeyRSC = KeyRSC;
        }