aboutsummaryrefslogtreecommitdiffstats
path: root/src/xterm.c
diff options
context:
space:
mode:
authorPaul Eggert2015-11-08 22:47:01 -0800
committerPaul Eggert2015-11-08 22:48:28 -0800
commit1087305574fd61256d66eb0c995f8bb74bd91afe (patch)
tree9f0052e41a56c785575727931ff4abb8e7dfa7e0 /src/xterm.c
parentbcca6a2a028d05af3cb5b31a5a2c997f3f1f1d31 (diff)
downloademacs-1087305574fd61256d66eb0c995f8bb74bd91afe.tar.gz
emacs-1087305574fd61256d66eb0c995f8bb74bd91afe.zip
Use INT_ADD_WRAPV etc. to check integer overflow
* src/alloc.c (xnmalloc, xnrealloc, xpalloc, Fmake_string): * src/buffer.c (record_overlay_string, overlay_strings): * src/casefiddle.c (casify_object): * src/ccl.c (Fccl_execute_on_string): * src/character.c (char_width, c_string_width, lisp_string_width) (count_size_as_multibyte, string_escape_byte8): * src/coding.c (coding_alloc_by_realloc, produce_chars): * src/data.c (arith_driver): * src/dispnew.c (realloc_glyph_pool, init_display): * src/editfns.c (styled_format): * src/fns.c (Ffillarray): * src/ftfont.c (ftfont_shape_by_flt): * src/gnutls.c (gnutls_hex_string): * src/gtkutil.c (get_utf8_string): * src/image.c (x_to_xcolors, x_detect_edges, png_load_body): * src/keymap.c (Fkey_description): * src/lisp.h (SAFE_ALLOCA_LISP): * src/term.c (encode_terminal_code): * src/tparam.c (tparam1): * src/xselect.c (x_property_data_to_lisp): * src/xsmfns.c (smc_save_yourself_CB): * src/xterm.c (x_term_init): When checking for integer overflow, prefer INT_MULTIPLY_WRAPV to more-complicated code involving division and/or INT_MULTIPLY_OVERFLOW, and similarly for INT_ADD_WRAPV and subtraction and/or INT_ADD_OVERFLOW. * src/casefiddle.c (casify_object): Simplify multibyte size check. * src/character.c: Remove some obsolete ‘#ifdef emacs’s. * src/data.c (arith_driver): Also check for division overflow, as that’s now possible given that the accumulator can now contain any Emacs integer. * src/lisp.h (lisp_word_count): Remove; no longer used.
Diffstat (limited to 'src/xterm.c')
-rw-r--r--src/xterm.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 5e9c16b8af4..5756378bd3a 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -11773,7 +11773,6 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
11773 struct terminal *terminal; 11773 struct terminal *terminal;
11774 struct x_display_info *dpyinfo; 11774 struct x_display_info *dpyinfo;
11775 XrmDatabase xrdb; 11775 XrmDatabase xrdb;
11776 ptrdiff_t lim;
11777 11776
11778 block_input (); 11777 block_input ();
11779 11778
@@ -11974,13 +11973,13 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
11974 XSetAfterFunction (x_current_display, x_trace_wire); 11973 XSetAfterFunction (x_current_display, x_trace_wire);
11975#endif 11974#endif
11976 11975
11977 lim = min (PTRDIFF_MAX, SIZE_MAX) - sizeof "@";
11978 Lisp_Object system_name = Fsystem_name (); 11976 Lisp_Object system_name = Fsystem_name ();
11979 if (lim - SBYTES (Vinvocation_name) < SBYTES (system_name)) 11977 ptrdiff_t nbytes;
11978 if (INT_ADD_WRAPV (SBYTES (Vinvocation_name), SBYTES (system_name) + 2,
11979 &nbytes))
11980 memory_full (SIZE_MAX); 11980 memory_full (SIZE_MAX);
11981 dpyinfo->x_id = ++x_display_id; 11981 dpyinfo->x_id = ++x_display_id;
11982 dpyinfo->x_id_name = xmalloc (SBYTES (Vinvocation_name) 11982 dpyinfo->x_id_name = xmalloc (nbytes);
11983 + SBYTES (system_name) + 2);
11984 char *nametail = lispstpcpy (dpyinfo->x_id_name, Vinvocation_name); 11983 char *nametail = lispstpcpy (dpyinfo->x_id_name, Vinvocation_name);
11985 *nametail++ = '@'; 11984 *nametail++ = '@';
11986 lispstpcpy (nametail, system_name); 11985 lispstpcpy (nametail, system_name);