aboutsummaryrefslogtreecommitdiffstats
path: root/src/lisp.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/lisp.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/lisp.h')
-rw-r--r--src/lisp.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/lisp.h b/src/lisp.h
index 1defda151ae..ad4614c7b16 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -766,6 +766,12 @@ extern EMACS_INT string_bytes (struct Lisp_String *);
766 766
767#endif /* not GC_CHECK_STRING_BYTES */ 767#endif /* not GC_CHECK_STRING_BYTES */
768 768
769/* A string cannot contain more bytes than a fixnum can represent,
770 nor can it be so long that C pointer arithmetic stops working on
771 the string plus a terminating null. */
772#define STRING_BYTES_MAX \
773 min (MOST_POSITIVE_FIXNUM, min (SIZE_MAX, PTRDIFF_MAX) - 1)
774
769/* Mark STR as a unibyte string. */ 775/* Mark STR as a unibyte string. */
770#define STRING_SET_UNIBYTE(STR) \ 776#define STRING_SET_UNIBYTE(STR) \
771 do { if (EQ (STR, empty_multibyte_string)) \ 777 do { if (EQ (STR, empty_multibyte_string)) \