Check for overflow when converting integer to cons and back.
commit201f31ae3de0b747b47863b93d6f6a747c36c960
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 3 Jun 2011 19:02:25 +0000 (3 12:02 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 3 Jun 2011 19:02:25 +0000 (3 12:02 -0700)
tree800c2c66fc648660cb957df676ea59cc911ae0fa
parentbe14b9ab109c8deb5745dc47cbc471e97be06486
Check for overflow when converting integer to cons and back.

* charset.c (Fdefine_charset_internal, Fdecode_char):
Use cons_to_unsigned to catch overflow.
(Fencode_char): Use INTEGER_TO_CONS.
* composite.h (LGLYPH_CODE): Use cons_to_unsigned.
(LGLYPH_SET_CODE): Use INTEGER_TO_CONS.
* data.c (long_to_cons, cons_to_long): Remove.
(cons_to_unsigned, cons_to_signed): New functions.
These signal an error for invalid or out-of-range values.
* dired.c (Ffile_attributes): Use INTEGER_TO_CONS.
* fileio.c (Fset_visited_file_modtime): Use CONS_TO_INTEGER.
* font.c (Ffont_variation_glyphs):
* fontset.c (Finternal_char_font): Use INTEGER_TO_CONS.
* lisp.h (INTEGER_TO_CONS, CONS_TO_INTEGER): New macros.
(cons_to_signed, cons_to_unsigned): New decls.
(long_to_cons, cons_to_long): Remove decls.
* undo.c (record_first_change): Use INTEGER_TO_CONS.
(Fprimitive_undo): Use CONS_TO_INTEGER.
* xfns.c (Fx_window_property): Likewise.
* xselect.c (x_own_selection, selection_data_to_lisp_data):
Use INTEGER_TO_CONS.
(x_handle_selection_request, x_handle_selection_clear)
(x_get_foreign_selection, Fx_disown_selection_internal)
(Fx_get_atom_name, x_send_client_event): Use CONS_TO_INTEGER.
(lisp_data_to_selection_data): Use cons_to_unsigned.
(x_fill_property_data): Use cons_to_signed.  Report values out of range.
12 files changed:
src/ChangeLog
src/charset.c
src/composite.h
src/data.c
src/dired.c
src/fileio.c
src/font.c
src/fontset.c
src/lisp.h
src/undo.c
src/xfns.c
src/xselect.c