patch-2.4.21 linux-2.4.21/fs/read_write.c
Next file: linux-2.4.21/fs/reiserfs/fix_node.c
Previous file: linux-2.4.21/fs/proc/proc_misc.c
Back to the patch index
Back to the overall index
- Lines: 31
- Date:
2003-06-13 07:51:37.000000000 -0700
- Orig file:
linux-2.4.20/fs/read_write.c
- Orig date:
2002-08-02 17:39:45.000000000 -0700
diff -urN linux-2.4.20/fs/read_write.c linux-2.4.21/fs/read_write.c
@@ -218,7 +218,7 @@
typedef ssize_t (*io_fn_t)(struct file *, char *, size_t, loff_t *);
typedef ssize_t (*iov_fn_t)(struct file *, const struct iovec *, unsigned long, loff_t *);
- ssize_t tot_len;
+ size_t tot_len;
struct iovec iovstack[UIO_FASTIOV];
struct iovec *iov=iovstack;
ssize_t ret, i;
@@ -259,12 +259,19 @@
tot_len = 0;
ret = -EINVAL;
for (i = 0 ; i < count ; i++) {
- 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;
tot_len += len;
- if (tot_len < tmp) /* maths overflow on the ssize_t */
+ /* We must do this work unsigned - signed overflow is
+ undefined and gcc 3.2 now uses that fact sometimes...
+
+ FIXME: put in a proper limits.h for each platform */
+#if BITS_PER_LONG==64
+ if (tot_len > 0x7FFFFFFFFFFFFFFFUL)
+#else
+ if (tot_len > 0x7FFFFFFFUL)
+#endif
goto out;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)