aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorPaul Eggert2011-09-27 08:58:20 -0700
committerPaul Eggert2011-09-27 08:58:20 -0700
commit2c6a9faaaebb2fca42c4f020865c7c077864cad8 (patch)
treefeee8819c9f6c93244985b5bb2ea2b91424c333e /src/coding.c
parentc801946a9290fe742d87053615495e68d04ec6be (diff)
downloademacs-2c6a9faaaebb2fca42c4f020865c7c077864cad8.tar.gz
emacs-2c6a9faaaebb2fca42c4f020865c7c077864cad8.zip
* coding.c: Integer and buffer overflow fixes.
(Funencodable_char_position, Fcheck_coding_systems_region) (get_translation, handle_composition_annotation, consume_chars): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. (consume_chars): Rewrite to avoid calculating an address outside buffer.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/coding.c b/src/coding.c
index 44506476794..25ac0e9764c 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -6613,8 +6613,8 @@ get_translation (Lisp_Object trans, int *buf, int *buf_end)
6613 { 6613 {
6614 Lisp_Object val = XCAR (trans); 6614 Lisp_Object val = XCAR (trans);
6615 Lisp_Object from = XCAR (val); 6615 Lisp_Object from = XCAR (val);
6616 int len = ASIZE (from); 6616 ptrdiff_t len = ASIZE (from);
6617 int i; 6617 ptrdiff_t i;
6618 6618
6619 for (i = 0; i < len; i++) 6619 for (i = 0; i < len; i++)
6620 { 6620 {
@@ -7132,7 +7132,7 @@ handle_composition_annotation (ptrdiff_t pos, ptrdiff_t limit,
7132 if (method != COMPOSITION_RELATIVE) 7132 if (method != COMPOSITION_RELATIVE)
7133 { 7133 {
7134 Lisp_Object components; 7134 Lisp_Object components;
7135 int len, i, i_byte; 7135 ptrdiff_t i, len, i_byte;
7136 7136
7137 components = COMPOSITION_COMPONENTS (prop); 7137 components = COMPOSITION_COMPONENTS (prop);
7138 if (VECTORP (components)) 7138 if (VECTORP (components))
@@ -7303,7 +7303,7 @@ consume_chars (struct coding_system *coding, Lisp_Object translation_table,
7303 *buf++ = c; 7303 *buf++ = c;
7304 else 7304 else
7305 { 7305 {
7306 int from_nchars = 1, to_nchars = 1; 7306 ptrdiff_t from_nchars = 1, to_nchars = 1;
7307 int *lookup_buf_end; 7307 int *lookup_buf_end;
7308 const unsigned char *p = src; 7308 const unsigned char *p = src;
7309 int i; 7309 int i;
@@ -7324,7 +7324,7 @@ consume_chars (struct coding_system *coding, Lisp_Object translation_table,
7324 else 7324 else
7325 { 7325 {
7326 to_nchars = ASIZE (trans); 7326 to_nchars = ASIZE (trans);
7327 if (buf + to_nchars > buf_end) 7327 if (buf_end - buf < to_nchars)
7328 break; 7328 break;
7329 c = XINT (AREF (trans, 0)); 7329 c = XINT (AREF (trans, 0));
7330 } 7330 }