]> git.baikalelectronics.ru Git - kernel.git/commit
net/af_iucv: right-size the uid variable in iucv_sock_bind()
authorJulian Wiedmann <jwi@linux.ibm.com>
Thu, 1 Oct 2020 17:21:26 +0000 (19:21 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sat, 3 Oct 2020 23:51:07 +0000 (16:51 -0700)
commit7d706c8def7c9e2a42cc5aa57b6fb417142e7745
treee6b24e67e48c80ef7c91eda7e5fa634b3de51a71
parent62a3434b520068c1f044c8442d1174b79ca83214
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 <jwi@linux.ibm.com>
Reviewed-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/iucv/af_iucv.c