aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2011-04-30 12:00:39 -0700
committerPaul Eggert2011-04-30 12:00:39 -0700
commitb5611f17a7bd64578fc43874a727a8f1081614e9 (patch)
tree575f9ea23b1573410f853a1da842fb661753ff50 /src
parentaec1708a5548072ba337a345fb72a184840eb0cb (diff)
parentdcb79f208ab9e2e1e8e0d4e9810ca25c1a660eaf (diff)
downloademacs-b5611f17a7bd64578fc43874a727a8f1081614e9.tar.gz
emacs-b5611f17a7bd64578fc43874a727a8f1081614e9.zip
Merge from mainline.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog40
-rw-r--r--src/coding.c10
-rw-r--r--src/doprnt.c22
-rw-r--r--src/dosfns.c6
-rw-r--r--src/eval.c2
-rw-r--r--src/fileio.c11
-rw-r--r--src/window.c20
7 files changed, 83 insertions, 28 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 0a9c3d88ca5..310d32a6432 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -12,8 +12,6 @@
12 (xd_remove_watch, Fdbus_init_bus, xd_read_queued_messages): Use 12 (xd_remove_watch, Fdbus_init_bus, xd_read_queued_messages): Use
13 SYMBOLP-guarded XSYMBOL, not XPNTR. 13 SYMBOLP-guarded XSYMBOL, not XPNTR.
14 14
152011-04-29 Paul Eggert <eggert@cs.ucla.edu>
16
17 * lisp.h (EMACS_INTPTR): Remove. All uses changed to intptr_t. 15 * lisp.h (EMACS_INTPTR): Remove. All uses changed to intptr_t.
18 (EMACS_UINTPTR): Likewise, with uintptr_t. 16 (EMACS_UINTPTR): Likewise, with uintptr_t.
19 17
@@ -54,8 +52,6 @@
54 Use a local to convert to proper width without a cast. 52 Use a local to convert to proper width without a cast.
55 * xmenu.c (dialog_selection_callback): Likewise. 53 * xmenu.c (dialog_selection_callback): Likewise.
56 54
572011-04-28 Paul Eggert <eggert@cs.ucla.edu>
58
59 * sysdep.c (get_random): Don't assume EMACS_INT is no wider than long. 55 * sysdep.c (get_random): Don't assume EMACS_INT is no wider than long.
60 Also, don't assume VALBITS / RAND_BITS is less than 5, 56 Also, don't assume VALBITS / RAND_BITS is less than 5,
61 and don't rely on undefined behavior when shifting a 1 left into 57 and don't rely on undefined behavior when shifting a 1 left into
@@ -79,6 +75,42 @@
79 75
80 * fns.c (Frandom): Let EMACS_UINT be wider than unsigned long. 76 * fns.c (Frandom): Let EMACS_UINT be wider than unsigned long.
81 77
782011-04-30 Eli Zaretskii <eliz@gnu.org>
79
80 * dosfns.c (Fint86, Fdos_memget, Fdos_memput): Use `ASIZE (FOO)'
81 rather than `XVECTOR (FOO)->size'.
82
83 * process.c: Remove HAVE_INTTYPES_H condition from inclusion of
84 inttypes.h, as a gnulib replacement is used if it not available in
85 system headers.
86
872011-04-21 Eli Zaretskii <eliz@gnu.org>
88
89 Lift the MOST_POSITIVE_FIXNUM/4 limitation on visited files.
90 * fileio.c (Finsert_file_contents): Don't limit file size to 1/4
91 of MOST_POSITIVE_FIXNUM. (Bug#8528)
92
93 * coding.c (coding_alloc_by_realloc): Error out if destination
94 will grow beyond MOST_POSITIVE_FIXNUM.
95 (decode_coding_emacs_mule): Abort if there isn't enough place in
96 charbuf for the composition carryover bytes. Reserve an extra
97 space for up to 2 characters produced in a loop.
98 (decode_coding_iso_2022): Abort if there isn't enough place in
99 charbuf for the composition carryover bytes.
100
1012011-04-21 Eli Zaretskii <eliz@gnu.org>
102
103 * doprnt.c (doprnt) [!HAVE_LONG_LONG_INT]: Error out instead of
104 aborting when %lld or %lll format is passed.
105 [!HAVE_UNSIGNED_LONG_LONG_INT]: Error out instead of aborting when
106 %llo or %llx format is passed. (Bug#8545)
107
108 * window.c (window_scroll_line_based): Use a marker instead of
109 simple variables to record original value of point. (Bug#7952)
110
111 * doprnt.c (doprnt): Fix the case where a multibyte sequence
112 produced by %s or %c overflows available buffer space. (Bug#8545)
113
822011-04-28 Paul Eggert <eggert@cs.ucla.edu> 1142011-04-28 Paul Eggert <eggert@cs.ucla.edu>
83 115
84 * doprnt.c (doprnt): Omit useless test; int overflow check (Bug#8545). 116 * doprnt.c (doprnt): Omit useless test; int overflow check (Bug#8545).
diff --git a/src/coding.c b/src/coding.c
index c129c94203c..d17346efdcb 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -1071,6 +1071,8 @@ coding_set_destination (struct coding_system *coding)
1071static void 1071static void
1072coding_alloc_by_realloc (struct coding_system *coding, EMACS_INT bytes) 1072coding_alloc_by_realloc (struct coding_system *coding, EMACS_INT bytes)
1073{ 1073{
1074 if (coding->dst_bytes >= MOST_POSITIVE_FIXNUM - bytes)
1075 error ("Maximum size of buffer or string exceeded");
1074 coding->destination = (unsigned char *) xrealloc (coding->destination, 1076 coding->destination = (unsigned char *) xrealloc (coding->destination,
1075 coding->dst_bytes + bytes); 1077 coding->dst_bytes + bytes);
1076 coding->dst_bytes += bytes; 1078 coding->dst_bytes += bytes;
@@ -2333,7 +2335,9 @@ decode_coding_emacs_mule (struct coding_system *coding)
2333 /* We may produce two annotations (charset and composition) in one 2335 /* We may produce two annotations (charset and composition) in one
2334 loop and one more charset annotation at the end. */ 2336 loop and one more charset annotation at the end. */
2335 int *charbuf_end 2337 int *charbuf_end
2336 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3); 2338 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3)
2339 /* We can produce up to 2 characters in a loop. */
2340 - 1;
2337 EMACS_INT consumed_chars = 0, consumed_chars_base; 2341 EMACS_INT consumed_chars = 0, consumed_chars_base;
2338 int multibytep = coding->src_multibyte; 2342 int multibytep = coding->src_multibyte;
2339 EMACS_INT char_offset = coding->produced_char; 2343 EMACS_INT char_offset = coding->produced_char;
@@ -2348,6 +2352,8 @@ decode_coding_emacs_mule (struct coding_system *coding)
2348 { 2352 {
2349 int i; 2353 int i;
2350 2354
2355 if (charbuf_end - charbuf < cmp_status->length)
2356 abort ();
2351 for (i = 0; i < cmp_status->length; i++) 2357 for (i = 0; i < cmp_status->length; i++)
2352 *charbuf++ = cmp_status->carryover[i]; 2358 *charbuf++ = cmp_status->carryover[i];
2353 coding->annotated = 1; 2359 coding->annotated = 1;
@@ -3479,6 +3485,8 @@ decode_coding_iso_2022 (struct coding_system *coding)
3479 3485
3480 if (cmp_status->state != COMPOSING_NO) 3486 if (cmp_status->state != COMPOSING_NO)
3481 { 3487 {
3488 if (charbuf_end - charbuf < cmp_status->length)
3489 abort ();
3482 for (i = 0; i < cmp_status->length; i++) 3490 for (i = 0; i < cmp_status->length; i++)
3483 *charbuf++ = cmp_status->carryover[i]; 3491 *charbuf++ = cmp_status->carryover[i];
3484 coding->annotated = 1; 3492 coding->annotated = 1;
diff --git a/src/doprnt.c b/src/doprnt.c
index e9a68f9d219..7b4bd35d5b1 100644
--- a/src/doprnt.c
+++ b/src/doprnt.c
@@ -269,7 +269,7 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
269 long long ll = va_arg (ap, long long); 269 long long ll = va_arg (ap, long long);
270 sprintf (sprintf_buffer, fmtcpy, ll); 270 sprintf (sprintf_buffer, fmtcpy, ll);
271#else 271#else
272 abort (); 272 error ("Invalid format operation %%ll%c", fmt[-1]);
273#endif 273#endif
274 } 274 }
275 else if (long_flag) 275 else if (long_flag)
@@ -299,7 +299,7 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
299 unsigned long long ull = va_arg (ap, unsigned long long); 299 unsigned long long ull = va_arg (ap, unsigned long long);
300 sprintf (sprintf_buffer, fmtcpy, ull); 300 sprintf (sprintf_buffer, fmtcpy, ull);
301#else 301#else
302 abort (); 302 error ("Invalid format operation %%ll%c", fmt[-1]);
303#endif 303#endif
304 } 304 }
305 else if (long_flag) 305 else if (long_flag)
@@ -367,9 +367,21 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
367 /* Truncate the string at character boundary. */ 367 /* Truncate the string at character boundary. */
368 tem = bufsize; 368 tem = bufsize;
369 while (!CHAR_HEAD_P (string[tem - 1])) tem--; 369 while (!CHAR_HEAD_P (string[tem - 1])) tem--;
370 memcpy (bufptr, string, tem); 370 /* If the multibyte sequence of this character is
371 /* We must calculate WIDTH again. */ 371 too long for the space we have left in the
372 width = strwidth (bufptr, tem); 372 buffer, truncate before it. */
373 if (tem > 0
374 && BYTES_BY_CHAR_HEAD (string[tem - 1]) > bufsize)
375 tem--;
376 if (tem > 0)
377 memcpy (bufptr, string, tem);
378 bufptr[tem] = 0;
379 /* Trigger exit from the loop, but make sure we
380 return to the caller a value which will indicate
381 that the buffer was too small. */
382 bufptr += bufsize;
383 bufsize = 0;
384 continue;
373 } 385 }
374 else 386 else
375 memcpy (bufptr, string, tem); 387 memcpy (bufptr, string, tem);
diff --git a/src/dosfns.c b/src/dosfns.c
index 3b9b2dbc038..e903ef20af0 100644
--- a/src/dosfns.c
+++ b/src/dosfns.c
@@ -62,7 +62,7 @@ REGISTERS should be a vector produced by `make-register' and
62 CHECK_NUMBER (interrupt); 62 CHECK_NUMBER (interrupt);
63 no = (unsigned long) XINT (interrupt); 63 no = (unsigned long) XINT (interrupt);
64 CHECK_VECTOR (registers); 64 CHECK_VECTOR (registers);
65 if (no < 0 || no > 0xff || XVECTOR (registers)-> size != 8) 65 if (no < 0 || no > 0xff || ASIZE (registers) != 8)
66 return Qnil; 66 return Qnil;
67 for (i = 0; i < 8; i++) 67 for (i = 0; i < 8; i++)
68 CHECK_NUMBER (XVECTOR (registers)->contents[i]); 68 CHECK_NUMBER (XVECTOR (registers)->contents[i]);
@@ -102,7 +102,7 @@ Return the updated VECTOR. */)
102 CHECK_NUMBER (address); 102 CHECK_NUMBER (address);
103 offs = (unsigned long) XINT (address); 103 offs = (unsigned long) XINT (address);
104 CHECK_VECTOR (vector); 104 CHECK_VECTOR (vector);
105 len = XVECTOR (vector)-> size; 105 len = ASIZE (vector);
106 if (len < 1 || len > 2048 || offs < 0 || offs > 0xfffff - len) 106 if (len < 1 || len > 2048 || offs < 0 || offs > 0xfffff - len)
107 return Qnil; 107 return Qnil;
108 buf = alloca (len); 108 buf = alloca (len);
@@ -125,7 +125,7 @@ DEFUN ("msdos-memput", Fdos_memput, Sdos_memput, 2, 2, 0,
125 CHECK_NUMBER (address); 125 CHECK_NUMBER (address);
126 offs = (unsigned long) XINT (address); 126 offs = (unsigned long) XINT (address);
127 CHECK_VECTOR (vector); 127 CHECK_VECTOR (vector);
128 len = XVECTOR (vector)-> size; 128 len = ASIZE (vector);
129 if (len < 1 || len > 2048 || offs < 0 || offs > 0xfffff - len) 129 if (len < 1 || len > 2048 || offs < 0 || offs > 0xfffff - len)
130 return Qnil; 130 return Qnil;
131 buf = alloca (len); 131 buf = alloca (len);
diff --git a/src/eval.c b/src/eval.c
index 88b8572a33e..0187cf96705 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1994,7 +1994,7 @@ verror (const char *m, va_list ap)
1994{ 1994{
1995 char buf[4000]; 1995 char buf[4000];
1996 size_t size = sizeof buf; 1996 size_t size = sizeof buf;
1997 size_t size_max = min (MOST_POSITIVE_FIXNUM, SIZE_MAX); 1997 size_t size_max = min (MOST_POSITIVE_FIXNUM, SIZE_MAX);
1998 size_t mlen = strlen (m); 1998 size_t mlen = strlen (m);
1999 char *buffer = buf; 1999 char *buffer = buf;
2000 size_t used; 2000 size_t used;
diff --git a/src/fileio.c b/src/fileio.c
index dcba6b6c0ae..7e6fd8c82a8 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3245,15 +3245,10 @@ variable `last-coding-system-used' to the coding system actually used. */)
3245 record_unwind_protect (close_file_unwind, make_number (fd)); 3245 record_unwind_protect (close_file_unwind, make_number (fd));
3246 3246
3247 3247
3248 /* Arithmetic overflow can occur if an Emacs integer cannot represent the 3248 /* Check whether the size is too large or negative, which can happen on a
3249 file size, or if the calculations below overflow. The calculations below 3249 platform that allows file sizes greater than the maximum off_t value. */
3250 double the file size twice, so check that it can be multiplied by 4
3251 safely.
3252
3253 Also check whether the size is negative, which can happen on a platform
3254 that allows file sizes greater than the maximum off_t value. */
3255 if (! not_regular 3250 if (! not_regular
3256 && ! (0 <= st.st_size && st.st_size <= MOST_POSITIVE_FIXNUM / 4)) 3251 && ! (0 <= st.st_size && st.st_size <= MOST_POSITIVE_FIXNUM))
3257 error ("Maximum buffer size exceeded"); 3252 error ("Maximum buffer size exceeded");
3258 3253
3259 /* Prevent redisplay optimizations. */ 3254 /* Prevent redisplay optimizations. */
diff --git a/src/window.c b/src/window.c
index b56ed84bc61..4dbee41c5f4 100644
--- a/src/window.c
+++ b/src/window.c
@@ -5076,7 +5076,12 @@ static void
5076window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror) 5076window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror)
5077{ 5077{
5078 register struct window *w = XWINDOW (window); 5078 register struct window *w = XWINDOW (window);
5079 register EMACS_INT opoint = PT, opoint_byte = PT_BYTE; 5079 /* Fvertical_motion enters redisplay, which can trigger
5080 fontification, which in turn can modify buffer text (e.g., if the
5081 fontification functions replace escape sequences with faces, as
5082 in `grep-mode-font-lock-keywords'). So we use a marker to record
5083 the old point position, to prevent crashes in SET_PT_BOTH. */
5084 Lisp_Object opoint_marker = Fpoint_marker ();
5080 register EMACS_INT pos, pos_byte; 5085 register EMACS_INT pos, pos_byte;
5081 register int ht = window_internal_height (w); 5086 register int ht = window_internal_height (w);
5082 register Lisp_Object tem; 5087 register Lisp_Object tem;
@@ -5126,7 +5131,8 @@ window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror)
5126 pos = PT; 5131 pos = PT;
5127 pos_byte = PT_BYTE; 5132 pos_byte = PT_BYTE;
5128 bolp = Fbolp (); 5133 bolp = Fbolp ();
5129 SET_PT_BOTH (opoint, opoint_byte); 5134 SET_PT_BOTH (marker_position (opoint_marker),
5135 marker_byte_position (opoint_marker));
5130 5136
5131 if (lose) 5137 if (lose)
5132 { 5138 {
@@ -5177,8 +5183,9 @@ window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror)
5177 else 5183 else
5178 top_margin = pos; 5184 top_margin = pos;
5179 5185
5180 if (top_margin <= opoint) 5186 if (top_margin <= marker_position (opoint_marker))
5181 SET_PT_BOTH (opoint, opoint_byte); 5187 SET_PT_BOTH (marker_position (opoint_marker),
5188 marker_byte_position (opoint_marker));
5182 else if (!NILP (Vscroll_preserve_screen_position)) 5189 else if (!NILP (Vscroll_preserve_screen_position))
5183 { 5190 {
5184 SET_PT_BOTH (pos, pos_byte); 5191 SET_PT_BOTH (pos, pos_byte);
@@ -5200,8 +5207,9 @@ window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror)
5200 else 5207 else
5201 bottom_margin = PT + 1; 5208 bottom_margin = PT + 1;
5202 5209
5203 if (bottom_margin > opoint) 5210 if (bottom_margin > marker_position (opoint_marker))
5204 SET_PT_BOTH (opoint, opoint_byte); 5211 SET_PT_BOTH (marker_position (opoint_marker),
5212 marker_byte_position (opoint_marker));
5205 else 5213 else
5206 { 5214 {
5207 if (!NILP (Vscroll_preserve_screen_position)) 5215 if (!NILP (Vscroll_preserve_screen_position))