tcp: '< 0' test on unsigned
Subsystems (3)
PATCH 1/1 tcp: '< 0' test on unsigned
or should this be fixed, with
if (!buf || len > x)
if so, what should x be?
This patch wasn't tested in any way. ------------------------------>8-------------8<--------------------------------- len is unsigned, so the '< 0' test won't work.
---
net/ipv4/tcp_probe.c +1 -1
@@ -167,7 +167,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf, {int error =0 , cnt =0 ; -if (!buf || len <0 ) +if (!buf || (ssize_t )len <0 )return -EINVAL ;while (cnt < len) {
Quoted 6 lines · Roel Kluin
net/ipv4/tcp_probe.c +0
-0
net/ipv4/tcp_probe.c static ssize_t tcpprobe_read(struct file *file, char __user *buf, · line 173
Quoted 8 lines
net/ipv4/tcp_probe.c +1
-1@@ -167,7 +167,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf, {int error =0 , cnt =0 ; -if (!buf || len <0 ) +if (!buf || (ssize_t )len <0 )return -EINVAL ;while (cnt < len) {
Either cnt needs to be promoted, or you need to limit len to INT_MAX.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtDavid Miller
maintainerFrom: Herbert Xu <[email protected]>
Date: Mon, 2 Mar 2009 12:30:56 +0800
Quoted 10 lines
Quoted 9 lines · Roel Kluin
net/ipv4/tcp_probe.c +0
-0@@ -167,7 +167,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf, {int error =0 , cnt =0 ;
Quoted 7 lines
net/ipv4/tcp_probe.c static ssize_t tcpprobe_read(struct file *file, char __user *buf, · line 173
Quoted 5 lines
net/ipv4/tcp_probe.c +1
-1-if (!buf || len <0 ) +if (!buf || (ssize_t )len <0 )return -EINVAL ;while (cnt < len) {Either cnt needs to be promoted, or you need to limit len to
INT_MAX.
Right, since the positive range of 'size_t' can exceed that of 'int'
Quoted 12 lines · David Miller
From: Herbert Xu <[email protected]>
Date: Mon, 2 Mar 2009 12:30:56 +0800Quoted 9 lines
Quoted 8 lines · Roel Kluin
net/ipv4/tcp_probe.c +0
-0@@ -167,7 +167,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf, {int error =0 , cnt =0 ;
Quoted 8 lines
Quoted 6 lines
net/ipv4/tcp_probe.c static ssize_t tcpprobe_read(struct file *file, char __user *buf, · line 173
Quoted 5 lines
net/ipv4/tcp_probe.c +1
-1-if (!buf || len <0 ) +if (!buf || (ssize_t )len <0 )return -EINVAL ;while (cnt < len) {Either cnt needs to be promoted, or you need to limit len to
INT_MAX.Right, since the positive range of '
size_t' can exceed that of 'int'
like this then? ------------------------------>8-------------8<--------------------------------- promote 'cnt' to size_t, to match 'len'.
---
net/ipv4/tcp_probe.c +3 -2
@@ -165,9 +165,10 @@ static int tcpprobe_sprint(char *tbuf, int n)static ssize_t tcpprobe_read (struct file *file,char __user *buf,size_t len,loff_t *ppos) { -int error =0 , cnt =0 ; +int error =0 ; +size_t cnt =0 ; -if (!buf || len <0 ) +if (!buf)return -EINVAL ;while (cnt < len) {
From: Roel Kluin <[email protected]>
Date: Mon, 02 Mar 2009 13:24:52 +0100
Quoted 6 lines
Quoted 5 lines · David Miller
From: Herbert Xu <[email protected]>
Date: Mon, 2 Mar 2009 12:30:56 +0800Quoted 1 line
Either cnt needs to be promoted, or you need to limit len to
INT_MAX.
Quoted 7 lines
Quoted 1 line
Right, since the positive range of '
size_t' can exceed that of 'int'like this then? ------------------------------>8-------------8<--------------------------------- promote 'cnt' to
size_t, to match 'len'.Signed-off-by Roel Kluin <[email protected]>
Applied, thanks.