2002-07-22 16:18:04

by Marcin Dalecki

[permalink] [raw]
Subject: [PATCH] 2.5.27 read_write - take 2

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;
}


Attachments:
read_write-2.5.27.diff (623.00 B)