diff options
Diffstat (limited to 'src/ChangeLog')
| -rw-r--r-- | src/ChangeLog | 83 |
1 files changed, 69 insertions, 14 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index a88e2e8e3cf..b525d83e288 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,7 +1,48 @@ | |||
| 1 | 2011-07-29 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2011-08-05 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | Integer and memory overflow issues. | 3 | Integer and memory overflow issues. |
| 4 | 4 | ||
| 5 | * charset.c (charset_table_size) | ||
| 6 | (struct charset_sort_data.priority): Now ptrdiff_t. | ||
| 7 | (charset_compare): Don't overflow if priorities differ greatly. | ||
| 8 | (Fsort_charsets): Don't assume list length fits in int. | ||
| 9 | Check for size-calculation overflow when allocating sort data. | ||
| 10 | (syms_of_charset): Allocate an initial charset table that is | ||
| 11 | just under 64 KiB, to avoid problems with glibc malloc and mmap. | ||
| 12 | |||
| 13 | * cmds.c (internal_self_insert): Check for size-calculation overflow. | ||
| 14 | |||
| 15 | * composite.h (struct composition.glyph_len): Now int, not unsigned. | ||
| 16 | The actual value is always <= INT_MAX, and leaving it unsigned made | ||
| 17 | overflow checking harder. | ||
| 18 | |||
| 19 | * dispextern.h (struct glyph_matrix.rows_allocated) | ||
| 20 | (struct face_cache.size): Now ptrdiff_t, for convenience in use | ||
| 21 | with xpalloc. The values are still always <= INT_MAX. | ||
| 22 | |||
| 23 | * indent.c (compute_motion): Adjust to region_cache_forward sig change. | ||
| 24 | |||
| 25 | * lisp.h (xnmalloc, xnrealloc, xpalloc): New decls. | ||
| 26 | (SAFE_NALLOCA): New macro. | ||
| 27 | |||
| 28 | * region-cache.c (struct boundary.pos, find_cache_boundary) | ||
| 29 | (move_cache_gap, insert_cache_boundary, delete_cache_boundaries) | ||
| 30 | (set_cache_region, invalidate_region_cache) | ||
| 31 | (revalidate_region_cache, know_region_cache, region_cache_forward) | ||
| 32 | (region_cache_backward, pp_cache): | ||
| 33 | Use ptrdiff_t, not EMACS_INT, since either will do. This is needed | ||
| 34 | so that ptrdiff_t * can be passed to xpalloc. | ||
| 35 | (struct region_cache): Similarly, for gap_start, gap_len, cache_len, | ||
| 36 | beg_unchanged, end_unchanged, buffer_beg, buffer_end members. | ||
| 37 | (pp_cache): Don't assume cache_len fits in int. | ||
| 38 | * region-cache.h: Adjust extern decls to match. | ||
| 39 | |||
| 40 | * search.c (scan_buffer, Freplace_match): Use ptrdiff_t, not | ||
| 41 | EMACS_INT, since either will do, for xpalloc. | ||
| 42 | |||
| 43 | * alloc.c: Include verify.h, and check that int fits in ptrdiff_t. | ||
| 44 | (xnmalloc, xnrealloc, xpalloc): New functions. | ||
| 45 | |||
| 5 | * bidi.c (bidi_shelve_header_size): New constant. | 46 | * bidi.c (bidi_shelve_header_size): New constant. |
| 6 | (bidi_cache_ensure_space, bidi_shelve_cache): Use it. | 47 | (bidi_cache_ensure_space, bidi_shelve_cache): Use it. |
| 7 | (bidi_cache_ensure_space): Avoid integer overflow when allocating. | 48 | (bidi_cache_ensure_space): Avoid integer overflow when allocating. |
| @@ -10,12 +51,21 @@ | |||
| 10 | (overlay_strings): | 51 | (overlay_strings): |
| 11 | Don't update size of array until after memory allocation succeeds, | 52 | Don't update size of array until after memory allocation succeeds, |
| 12 | because xmalloc/xrealloc may not return. | 53 | because xmalloc/xrealloc may not return. |
| 54 | (struct sortstrlist.bytes): Now ptrdiff_t, as EMACS_INT doesn't help | ||
| 55 | now that we have proper integer overflow checking. | ||
| 56 | (record_overlay_string, overlay_strings): Catch overflows when | ||
| 57 | calculating size of overlay_str_buf. | ||
| 13 | 58 | ||
| 14 | * callproc.c (child_setup): Don't assume strlen fits in int. | 59 | * callproc.c (Fcall_process): Check for size overflow when |
| 60 | calculating size of args2. | ||
| 61 | (child_setup): Avoid overflow by using size_t rather than ptrdiff_t. | ||
| 62 | Normally we prefer signed values, but sticking with ptrdiff_t would | ||
| 63 | require adding more-complicated checks. | ||
| 15 | 64 | ||
| 16 | * ccl.c (Fccl_execute_on_string): Check for memory overflow. | 65 | * ccl.c (Fccl_execute_on_string): Check for memory overflow. |
| 17 | Use ptrdiff_t rather than EMACS_INT where ptrdiff_t will do. | 66 | Use ptrdiff_t rather than EMACS_INT where ptrdiff_t will do. |
| 18 | Redo buffer-overflow calculations to avoid integer overflow. | 67 | Redo buffer-overflow calculations to avoid integer overflow. |
| 68 | Add a FIXME comment where memory seems to be over-allocated. | ||
| 19 | 69 | ||
| 20 | * character.c (Fstring): Check for size-calculation overflow. | 70 | * character.c (Fstring): Check for size-calculation overflow. |
| 21 | 71 | ||
| @@ -55,7 +105,10 @@ | |||
| 55 | Don't assume message length fits in int. | 105 | Don't assume message length fits in int. |
| 56 | (Fformat): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t will do. | 106 | (Fformat): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t will do. |
| 57 | 107 | ||
| 58 | * emacs.c (main, sort_args): Check for size-calculation overflow. | 108 | * emacs.c (main): Do not reallocate argv, since there is a null at |
| 109 | the end that can be overwritten, and this way there's no need to | ||
| 110 | worry about size-calculation overflow. | ||
| 111 | (sort_args): Check for size-calculation overflow. | ||
| 59 | 112 | ||
| 60 | * eval.c (init_eval_once, grow_specpdl): Don't update size until | 113 | * eval.c (init_eval_once, grow_specpdl): Don't update size until |
| 61 | alloc succeeds. | 114 | alloc succeeds. |
| @@ -119,9 +172,6 @@ | |||
| 119 | * macros.c (Fstart_kbd_macro): Don't update size until alloc done. | 172 | * macros.c (Fstart_kbd_macro): Don't update size until alloc done. |
| 120 | (store_kbd_macro_char): Reorder multiplicands to avoid overflow. | 173 | (store_kbd_macro_char): Reorder multiplicands to avoid overflow. |
| 121 | 174 | ||
| 122 | * minibuf.c (read_minibuf_noninteractive): Don't leak memory | ||
| 123 | on memory overflow. | ||
| 124 | |||
| 125 | * nsterm.h (struct ns_color_table.size, struct ns_color_table.avail): | 175 | * nsterm.h (struct ns_color_table.size, struct ns_color_table.avail): |
| 126 | Now ptrdiff_t, not int. | 176 | Now ptrdiff_t, not int. |
| 127 | * nsterm.m (ns_index_color): Use ptrdiff_t, not int, for table indexes. | 177 | * nsterm.m (ns_index_color): Use ptrdiff_t, not int, for table indexes. |
| @@ -161,25 +211,29 @@ | |||
| 161 | Don't update size until alloc done. | 211 | Don't update size until alloc done. |
| 162 | Redo size calculations to avoid overflow. | 212 | Redo size calculations to avoid overflow. |
| 163 | Check for size calculation overflow. | 213 | Check for size calculation overflow. |
| 214 | (main) [DEBUG]: Fix typo in invoking tparam1. | ||
| 164 | 215 | ||
| 165 | * xdisp.c (store_mode_line_noprop_char, x_consider_frame_title): | 216 | * xdisp.c (store_mode_line_noprop_char, x_consider_frame_title): |
| 166 | Use ptrdiff_t, not int, for sizes. | 217 | Use ptrdiff_t, not int, for sizes. |
| 167 | (store_mode_line_noprop_char): Don't update size until alloc done. | 218 | (store_mode_line_noprop_char): Don't update size until alloc done. |
| 168 | 219 | ||
| 169 | * xfaces.c (Finternal_make_lisp_face): Use ptrdiff_t, not int, for | 220 | * xfaces.c (lface_id_to_name_size, Finternal_make_lisp_face): |
| 170 | sizes. Check for size calculation overflow. | 221 | Use ptrdiff_t, not int, for sizes. |
| 171 | (cache_face): Do not overflow in size calculation. | 222 | (Finternal_make_lisp_face, cache_face): |
| 223 | Check for size calculation overflow. | ||
| 224 | (cache_face): Treat size calculation overflows as if they were | ||
| 225 | memory exhaustion (the usual treatment), rather than aborting. | ||
| 172 | 226 | ||
| 173 | * xfns.c (x_encode_text, x_set_name_internal) | 227 | * xfns.c (x_encode_text, x_set_name_internal) |
| 174 | (Fx_change_window_property): Use ptrdiff_t, not int, to count | 228 | (Fx_change_window_property): Use ptrdiff_t, not int, to count |
| 175 | sizes, since they can exceed INT_MAX in size. Check for size | 229 | sizes, since they can exceed INT_MAX in size. Check for size |
| 176 | calculation overflow. | 230 | calculation overflow. |
| 177 | 231 | ||
| 178 | * xgselect.c (xg_select): Check for size calculation overflow. | 232 | * xgselect.c (gfds_size): Now ptrdiff_t, for convenience with xpalloc. |
| 233 | (xg_select): Check for size calculation overflow. | ||
| 179 | Don't update size until alloc done. | 234 | Don't update size until alloc done. |
| 180 | 235 | ||
| 181 | * xrdb.c (magic_file_p): Plug memory leak on size overflow. | 236 | * xrdb.c (get_environ_db): Don't assume path length fits in int, |
| 182 | (get_environ_db): Don't assume path length fits in int, | ||
| 183 | as sprintf is limited to int lengths. | 237 | as sprintf is limited to int lengths. |
| 184 | 238 | ||
| 185 | * xselect.c (X_LONG_SIZE, X_USHRT_MAX, X_ULONG_MAX): New macros. | 239 | * xselect.c (X_LONG_SIZE, X_USHRT_MAX, X_ULONG_MAX): New macros. |
| @@ -229,10 +283,11 @@ | |||
| 229 | 283 | ||
| 230 | * xsmfns.c (smc_save_yourself_CB): Check for size calc overflow. | 284 | * xsmfns.c (smc_save_yourself_CB): Check for size calc overflow. |
| 231 | 285 | ||
| 232 | * xterm.c (x_color_cells, handle_one_xevent, x_term_init): | 286 | * xterm.c (x_color_cells, x_send_scrollbar_event, handle_one_xevent) |
| 233 | Check for size calculation overflow. | 287 | (x_term_init): Check for size calculation overflow. |
| 234 | (x_color_cells): Don't store size until memory allocation succeeds. | 288 | (x_color_cells): Don't store size until memory allocation succeeds. |
| 235 | (handle_one_xevent): Use ptrdiff_t, not int, for byte counts. | 289 | (handle_one_xevent): Use ptrdiff_t, not int, for byte counts. |
| 290 | Don't assume alloca size is less than MAX_ALLOCA. | ||
| 236 | (x_term_init): Don't assume length fits in int (sprintf is limited | 291 | (x_term_init): Don't assume length fits in int (sprintf is limited |
| 237 | to int size). | 292 | to int size). |
| 238 | 293 | ||