aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.h
diff options
context:
space:
mode:
authorPaul Eggert2011-09-02 22:23:17 -0700
committerPaul Eggert2011-09-02 22:23:17 -0700
commit728f8f0a00a22e544789952c76f9eac0c3f8b2c6 (patch)
tree15415449894cb74cc1f09c1fe5a7bc3869a17bf2 /src/buffer.h
parent9af32a1a25d9619e17abfb8a21b2938017cf56b3 (diff)
downloademacs-728f8f0a00a22e544789952c76f9eac0c3f8b2c6.tar.gz
emacs-728f8f0a00a22e544789952c76f9eac0c3f8b2c6.zip
* fileio.c: Fix bugs with large file offsets.
The previous code assumed that file offsets (off_t values) fit in EMACS_INT variables, which is not true on typical 32-bit hosts. The code messed up by falsely reporting buffer overflow in cases such as (insert-file-contents "big" nil 1 2) into an empty buffer when "big" contains more than 2**29 bytes, even though this inserts just one byte and does not overflow the buffer. (Finsert_file_contents): Store file offsets as off_t values, not as EMACS_INT values. Check for overflow when converting between EMACS_INT and off_t. When checking for buffer overflow or for overlap, take the offsets into account. Don't use EMACS_INT for small values where int suffices. When checking for overlap, fix a typo: ZV was used where ZV_BYTE was intended. (Fwrite_region): Don't assume off_t fits into 'long'. * buffer.h (struct buffer.modtime_size): Now off_t, not EMACS_INT.
Diffstat (limited to 'src/buffer.h')
-rw-r--r--src/buffer.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/buffer.h b/src/buffer.h
index 06864dd5789..c50cfe56c77 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -559,7 +559,7 @@ struct buffer
559 is still the same (since it's rounded up to seconds) but we're actually 559 is still the same (since it's rounded up to seconds) but we're actually
560 not up-to-date. -1 means the size is unknown. Only meaningful if 560 not up-to-date. -1 means the size is unknown. Only meaningful if
561 modtime is actually set. */ 561 modtime is actually set. */
562 EMACS_INT modtime_size; 562 off_t modtime_size;
563 /* The value of text->modiff at the last auto-save. */ 563 /* The value of text->modiff at the last auto-save. */
564 int auto_save_modified; 564 int auto_save_modified;
565 /* The value of text->modiff at the last display error. 565 /* The value of text->modiff at the last display error.