summaryrefslogtreecommitdiff
path: root/src/fileio.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2011-06-16 14:18:12 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2011-06-16 14:18:12 -0700
commit1c8e352f7e4291ab523996e7c5feaedfe0f4b350 (patch)
tree3adb22fb15a891521047080018b22e454ba5c471 /src/fileio.c
parent21d890a4ecf97141f3c3f7e373bca6d083662a83 (diff)
downloademacs-1c8e352f7e4291ab523996e7c5feaedfe0f4b350.tar.gz
emacs-1c8e352f7e4291ab523996e7c5feaedfe0f4b350.tar.bz2
emacs-1c8e352f7e4291ab523996e7c5feaedfe0f4b350.zip
Improve buffer-overflow checking.
* fileio.c (Finsert_file_contents): * insdel.c (insert_from_buffer_1, replace_range, replace_range_2): Remove the old (too-loose) buffer overflow checks. They weren't needed, since make_gap checks for buffer overflow. * insdel.c (make_gap_larger): Catch buffer overflows that were missed. The old code merely checked for Emacs fixnum overflow, and relied on undefined (wraparound) behavior. The new code avoids undefined behavior, and also checks for ptrdiff_t and/or size_t overflow.
Diffstat (limited to 'src/fileio.c')
-rw-r--r--src/fileio.c11
1 files changed, 1 insertions, 10 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 4458a3a4807..dd34872c263 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3800,16 +3800,7 @@ variable `last-coding-system-used' to the coding system actually used. */)
}
if (! not_regular)
- {
- register Lisp_Object temp;
-
- total = XINT (end) - XINT (beg);
-
- /* Make sure point-max won't overflow after this insertion. */
- XSETINT (temp, total);
- if (total != XINT (temp))
- buffer_overflow ();
- }
+ total = XINT (end) - XINT (beg);
else
/* For a special file, all we can do is guess. */
total = READ_BUF_SIZE;