diff options
| author | Paul Eggert | 2011-06-06 01:29:01 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-06-06 01:29:01 -0700 |
| commit | be44ca6cd47bff4cb0dfcfd71aa14f10fdab5434 (patch) | |
| tree | 34110ed6783c1314604f3382e8cd6d0812b939e3 /src/undo.c | |
| parent | d1f3d2afe1057a99b9dec6d1bd5b57bfee81fdff (diff) | |
| download | emacs-be44ca6cd47bff4cb0dfcfd71aa14f10fdab5434.tar.gz emacs-be44ca6cd47bff4cb0dfcfd71aa14f10fdab5434.zip | |
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: Include <intprops.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: Include <limits.h>.
(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.
Diffstat (limited to 'src/undo.c')
| -rw-r--r-- | src/undo.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/undo.c b/src/undo.c index 142960545a7..e7e9ae5632e 100644 --- a/src/undo.c +++ b/src/undo.c | |||
| @@ -212,7 +212,6 @@ record_change (EMACS_INT beg, EMACS_INT length) | |||
| 212 | void | 212 | void |
| 213 | record_first_change (void) | 213 | record_first_change (void) |
| 214 | { | 214 | { |
| 215 | Lisp_Object high, low; | ||
| 216 | struct buffer *base_buffer = current_buffer; | 215 | struct buffer *base_buffer = current_buffer; |
| 217 | 216 | ||
| 218 | if (EQ (BVAR (current_buffer, undo_list), Qt)) | 217 | if (EQ (BVAR (current_buffer, undo_list), Qt)) |
| @@ -225,9 +224,9 @@ record_first_change (void) | |||
| 225 | if (base_buffer->base_buffer) | 224 | if (base_buffer->base_buffer) |
| 226 | base_buffer = base_buffer->base_buffer; | 225 | base_buffer = base_buffer->base_buffer; |
| 227 | 226 | ||
| 228 | XSETFASTINT (high, (base_buffer->modtime >> 16) & 0xffff); | 227 | BVAR (current_buffer, undo_list) = |
| 229 | XSETFASTINT (low, base_buffer->modtime & 0xffff); | 228 | Fcons (Fcons (Qt, INTEGER_TO_CONS (base_buffer->modtime)), |
| 230 | BVAR (current_buffer, undo_list) = Fcons (Fcons (Qt, Fcons (high, low)), BVAR (current_buffer, undo_list)); | 229 | BVAR (current_buffer, undo_list)); |
| 231 | } | 230 | } |
| 232 | 231 | ||
| 233 | /* Record a change in property PROP (whose old value was VAL) | 232 | /* Record a change in property PROP (whose old value was VAL) |
| @@ -499,13 +498,9 @@ Return what remains of the list. */) | |||
| 499 | if (EQ (car, Qt)) | 498 | if (EQ (car, Qt)) |
| 500 | { | 499 | { |
| 501 | /* Element (t high . low) records previous modtime. */ | 500 | /* Element (t high . low) records previous modtime. */ |
| 502 | Lisp_Object high, low; | ||
| 503 | time_t mod_time; | ||
| 504 | struct buffer *base_buffer = current_buffer; | 501 | struct buffer *base_buffer = current_buffer; |
| 505 | 502 | time_t mod_time; | |
| 506 | high = Fcar (cdr); | 503 | CONS_TO_INTEGER (cdr, time_t, mod_time); |
| 507 | low = Fcdr (cdr); | ||
| 508 | mod_time = (XFASTINT (high) << 16) + XFASTINT (low); | ||
| 509 | 504 | ||
| 510 | if (current_buffer->base_buffer) | 505 | if (current_buffer->base_buffer) |
| 511 | base_buffer = current_buffer->base_buffer; | 506 | base_buffer = current_buffer->base_buffer; |