aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.h
diff options
context:
space:
mode:
authorPaul Eggert2011-06-03 19:49:51 -0700
committerPaul Eggert2011-06-03 19:49:51 -0700
commitedaa182249601b0f7ee36f9863243b6919943982 (patch)
tree1e399289df34c433f0471efdfb8a6da4ab05ac25 /src/buffer.h
parentc6c3615fb23e438701da089110b645fc771f8087 (diff)
downloademacs-edaa182249601b0f7ee36f9863243b6919943982.tar.gz
emacs-edaa182249601b0f7ee36f9863243b6919943982.zip
Check for buffer and string overflow more precisely.
* buffer.h (BUF_BYTES_MAX): New macro. * lisp.h (STRING_BYTES_MAX): New macro. * alloc.c (Fmake_string): * character.c (string_escape_byte8): * coding.c (coding_alloc_by_realloc): * doprnt.c (doprnt): * editfns.c (Fformat): * eval.c (verror): Use STRING_BYTES_MAX, not MOST_POSITIVE_FIXNUM, since they may not be the same number. * editfns.c (Finsert_char): * fileio.c (Finsert_file_contents): Likewise for BUF_BYTES_MAX.
Diffstat (limited to 'src/buffer.h')
-rw-r--r--src/buffer.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/buffer.h b/src/buffer.h
index 8c64a24e804..3c91bdfe570 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -306,6 +306,11 @@ do \
306 } \ 306 } \
307while (0) 307while (0)
308 308
309/* Maximum number of bytes in a buffer.
310 A buffer cannot contain more bytes than a 1-origin fixnum can represent,
311 nor can it be so large that C pointer arithmetic stops working. */
312#define BUF_BYTES_MAX min (MOST_POSITIVE_FIXNUM - 1, min (SIZE_MAX, PTRDIFF_MAX))
313
309/* Return the address of byte position N in current buffer. */ 314/* Return the address of byte position N in current buffer. */
310 315
311#define BYTE_POS_ADDR(n) \ 316#define BYTE_POS_ADDR(n) \