aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorPaul Eggert2011-06-05 23:16:12 -0700
committerPaul Eggert2011-06-05 23:16:12 -0700
commitd1f3d2afe1057a99b9dec6d1bd5b57bfee81fdff (patch)
treef471bdf3143b2d4ba0cf2d4c4e530304b7a67c88 /src/coding.c
parentdd52fcea063f37a9875bf9196dbe11a442e8adfc (diff)
downloademacs-d1f3d2afe1057a99b9dec6d1bd5b57bfee81fdff.tar.gz
emacs-d1f3d2afe1057a99b9dec6d1bd5b57bfee81fdff.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/coding.c')
-rw-r--r--src/coding.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/coding.c b/src/coding.c
index 6ccaf354c74..64e8e41a5a1 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -1071,8 +1071,8 @@ coding_set_destination (struct coding_system *coding)
1071static void 1071static void
1072coding_alloc_by_realloc (struct coding_system *coding, EMACS_INT bytes) 1072coding_alloc_by_realloc (struct coding_system *coding, EMACS_INT bytes)
1073{ 1073{
1074 if (coding->dst_bytes >= MOST_POSITIVE_FIXNUM - bytes) 1074 if (STRING_BYTES_MAX - coding->dst_bytes < bytes)
1075 error ("Maximum size of buffer or string exceeded"); 1075 string_overflow ();
1076 coding->destination = (unsigned char *) xrealloc (coding->destination, 1076 coding->destination = (unsigned char *) xrealloc (coding->destination,
1077 coding->dst_bytes + bytes); 1077 coding->dst_bytes + bytes);
1078 coding->dst_bytes += bytes; 1078 coding->dst_bytes += bytes;