rose: Fix signedness issues wrt. digi count.
Subsystems (2)
David Miller
maintainerPATCH 1/1 rose: Fix signedness issues wrt. digi count.
Just use explicit casts, since we really can't change the types of structures exported to userspace which have been around for 15 years or so.
Reported-by Dan Rosenberg <[email protected]>
Signed-off-by David S. Miller <[email protected]>
---
The only two cases are bind() and connect(). And we only need to guard against negative (ie. very large unsigned) values, the other tests against addr->srose_ndigis are sane as long as we make this check.
Committed to net-2.6
net/rose/af_rose.c +2 -2
@@ -679,7 +679,7 @@ static int rose_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)if (addr_len ==sizeof (struct sockaddr_rose ) && addr->srose_ndigis >1 )return -EINVAL ; -if (addr->srose_ndigis >ROSE_MAX_DIGIS ) +if ((unsigned int ) addr->srose_ndigis >ROSE_MAX_DIGIS )return -EINVAL ;if ((dev =rose_dev_get (&addr->srose_addr)) ==NULL ) {
@@ -739,7 +739,7 @@ static int rose_connect(struct socket *sock, struct sockaddr *uaddr, int addr_leif (addr_len ==sizeof (struct sockaddr_rose ) && addr->srose_ndigis >1 )return -EINVAL ; -if (addr->srose_ndigis >ROSE_MAX_DIGIS ) +if ((unsigned int ) addr->srose_ndigis >ROSE_MAX_DIGIS )return -EINVAL ;/* Source + Destination digis should not exceed ROSE_MAX_DIGIS */