Skip to content

Commit

Permalink
airo: airo_get_encode{,ext} potential buffer overflow
Browse files Browse the repository at this point in the history
Feeding the return code of get_wep_key directly to the length parameter
of memcpy is a bad idea since it could be -1...

Reported-by: Eugene Teo <eugeneteo@kernel.sg>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
John W. Linville committed May 11, 2009
1 parent e1cc1c5 commit aedec92
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions drivers/net/wireless/airo.c
Original file line number Diff line number Diff line change
Expand Up @@ -6501,7 +6501,10 @@ static int airo_get_encode(struct net_device *dev,

/* Copy the key to the user buffer */
dwrq->length = get_wep_key(local, index, &buf[0], sizeof(buf));
memcpy(extra, buf, dwrq->length);
if (dwrq->length != -1)
memcpy(extra, buf, dwrq->length);
else
dwrq->length = 0;

return 0;
}
Expand Down Expand Up @@ -6659,7 +6662,10 @@ static int airo_get_encodeext(struct net_device *dev,

/* Copy the key to the user buffer */
ext->key_len = get_wep_key(local, idx, &buf[0], sizeof(buf));
memcpy(extra, buf, ext->key_len);
if (ext->key_len != -1)
memcpy(extra, buf, ext->key_len);
else
ext->key_len = 0;

return 0;
}
Expand Down

0 comments on commit aedec92

Please sign in to comment.