aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.h
diff options
context:
space:
mode:
authorPaul Eggert2011-06-16 14:25:42 -0700
committerPaul Eggert2011-06-16 14:25:42 -0700
commit393d71f34cd42b77afe78fbd174f2b1377182232 (patch)
treebb4efa252030d2a65cbf521bf603e9bc403c7c16 /src/buffer.h
parent0cca0a78a4ee6b761c2fd91ee5a6628f23e3368c (diff)
parent4847e3f0a94e3f24b40b060af528cf4b51d788c5 (diff)
downloademacs-393d71f34cd42b77afe78fbd174f2b1377182232.tar.gz
emacs-393d71f34cd42b77afe78fbd174f2b1377182232.zip
Improve buffer-overflow checking (Bug#8873).
Diffstat (limited to 'src/buffer.h')
-rw-r--r--src/buffer.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/buffer.h b/src/buffer.h
index dc1d62beb00..a13351b5ea6 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -309,8 +309,10 @@ while (0)
309 309
310/* Maximum number of bytes in a buffer. 310/* Maximum number of bytes in a buffer.
311 A buffer cannot contain more bytes than a 1-origin fixnum can represent, 311 A buffer cannot contain more bytes than a 1-origin fixnum can represent,
312 nor can it be so large that C pointer arithmetic stops working. */ 312 nor can it be so large that C pointer arithmetic stops working.
313#define BUF_BYTES_MAX min (MOST_POSITIVE_FIXNUM - 1, min (SIZE_MAX, PTRDIFF_MAX)) 313 The ptrdiff_t cast ensures that this is signed, not unsigned. */
314#define BUF_BYTES_MAX \
315 (ptrdiff_t) min (MOST_POSITIVE_FIXNUM - 1, min (SIZE_MAX, PTRDIFF_MAX))
314 316
315/* Return the address of byte position N in current buffer. */ 317/* Return the address of byte position N in current buffer. */
316 318