diff -urN linux-2.5.27/fs/read_write.c linux/fs/read_write.c --- linux-2.5.27/fs/read_write.c 2002-07-22 17:51:25.000000000 +0200 +++ linux/fs/read_write.c 2002-07-22 17:57:22.000000000 +0200 @@ -306,12 +306,16 @@ tot_len = 0; ret = -EINVAL; for (i = 0 ; i < count ; i++) { - size_t tmp = tot_len; - int len = iov[i].iov_len; + ssize_t tmp = tot_len; + ssize_t len = iov[i].iov_len; + + /* check for SSIZE_MAX overflow */ if (len < 0) goto out; - (u32)tot_len += len; - if (tot_len < tmp || tot_len < (u32)len) + + tot_len += len; + /* check for overflows */ + if (tot_len < tmp) goto out; }