lkml.org 
[lkml]   [2002]   [Jul]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectPATCH: 2.5.28 (resend #1) SuS/LSB compliance in readv/writev from 2.4
Date
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux-2.5.28/fs/read_write.c linux-2.5.28-ac1/fs/read_write.c
--- linux-2.5.28/fs/read_write.c Thu Jul 25 10:51:25 2002
+++ linux-2.5.28-ac1/fs/read_write.c Mon Jul 22 15:43:46 2002
@@ -301,17 +301,23 @@
if (copy_from_user(iov, vector, count*sizeof(*vector)))
goto out;

- /* BSD readv/writev returns EINVAL if one of the iov_len
- values < 0 or tot_len overflowed a 32-bit integer. -ink */
+ /*
+ * Single unix specification:
+ * We should -EINVAL if an element length is not >= 0 and fitting an ssize_t
+ * The total length is fitting an ssize_t
+ *
+ * Be careful here because iov_len is a size_t not an ssize_t
+ */
+
tot_len = 0;
ret = -EINVAL;
for (i = 0 ; i < count ; i++) {
- size_t tmp = tot_len;
- int len = iov[i].iov_len;
- if (len < 0)
+ ssize_t tmp = tot_len;
+ ssize_t len = (ssize_t)iov[i].iov_len;
+ if (len < 0) /* size_t not fitting an ssize_t .. */
goto out;
- (u32)tot_len += len;
- if (tot_len < tmp || tot_len < (u32)len)
+ tot_len += len;
+ if (tot_len < tmp) /* maths overflow on the ssize_t */
goto out;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 13:27    [W:0.961 / U:1.468 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site