comparison src/fileio.c @ 91302:56a72e2bd635

Merge from emacs--devo--0 Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-306
author Miles Bader <miles@gnu.org>
date Sat, 29 Dec 2007 02:39:17 +0000
parents 2a54f2cb1b4b d40e3ce78801
children 606f2d163a64
comparison
equal deleted inserted replaced
91301:7774e5860c70 91302:56a72e2bd635
19 along with GNU Emacs; see the file COPYING. If not, write to 19 along with GNU Emacs; see the file COPYING. If not, write to
20 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */ 21 Boston, MA 02110-1301, USA. */
22 22
23 #include <config.h> 23 #include <config.h>
24 #include <limits.h>
24 25
25 #ifdef HAVE_FCNTL_H 26 #ifdef HAVE_FCNTL_H
26 #include <fcntl.h> 27 #include <fcntl.h>
27 #endif 28 #endif
28 29
3880 /* Arithmetic overflow can occur if an Emacs integer cannot 3881 /* Arithmetic overflow can occur if an Emacs integer cannot
3881 represent the file size, or if the calculations below 3882 represent the file size, or if the calculations below
3882 overflow. The calculations below double the file size 3883 overflow. The calculations below double the file size
3883 twice, so check that it can be multiplied by 4 safely. */ 3884 twice, so check that it can be multiplied by 4 safely. */
3884 if (XINT (end) != st.st_size 3885 if (XINT (end) != st.st_size
3885 || ((int) st.st_size * 4) / 4 != st.st_size) 3886 || st.st_size > INT_MAX / 4)
3886 error ("Maximum buffer size exceeded"); 3887 error ("Maximum buffer size exceeded");
3887 3888
3888 /* The file size returned from stat may be zero, but data 3889 /* The file size returned from stat may be zero, but data
3889 may be readable nonetheless, for example when this is a 3890 may be readable nonetheless, for example when this is a
3890 file in the /proc filesystem. */ 3891 file in the /proc filesystem. */