Skip to content

Commit 398999b

Browse files
julianwiedmanndavem330
authored andcommitted
net/af_iucv: right-size the uid variable in iucv_sock_bind()
smatch complains about net/iucv/af_iucv.c:624 iucv_sock_bind() error: memcpy() 'sa->siucv_user_id' too small (8 vs 9) Which is absolutely correct - the memcpy() takes 9 bytes (sizeof(uid)) from an 8-byte field (sa->siucv_user_id). Luckily the sockaddr_iucv struct contains more data after the .siucv_user_id field, and we checked the size of the passed data earlier on. So the memcpy() won't accidentally read from an invalid location. Fix the warning by reducing the size of the uid variable to what's actually needed, and thus reducing the amount of copied data. Signed-off-by: Julian Wiedmann <[email protected]> Reviewed-by: Karsten Graul <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8e1b388 commit 398999b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/iucv/af_iucv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,11 +588,11 @@ static int iucv_sock_bind(struct socket *sock, struct sockaddr *addr,
588588
int addr_len)
589589
{
590590
struct sockaddr_iucv *sa = (struct sockaddr_iucv *) addr;
591+
char uid[sizeof(sa->siucv_user_id)];
591592
struct sock *sk = sock->sk;
592593
struct iucv_sock *iucv;
593594
int err = 0;
594595
struct net_device *dev;
595-
char uid[9];
596596

597597
/* Verify the input sockaddr */
598598
if (addr_len < sizeof(struct sockaddr_iucv) ||

0 commit comments

Comments
 (0)