diff options
| author | Joakim Verona | 2012-11-13 04:09:58 +0100 |
|---|---|---|
| committer | Joakim Verona | 2012-11-13 04:09:58 +0100 |
| commit | a9c1b612eb2a05d7a3aed3d7fb1dc589c47a6998 (patch) | |
| tree | 11a8506533cdc82e17050c204881b52c603ced60 /src | |
| parent | 7e6182661522fa7d83d7f08c10d97e4ee40671fd (diff) | |
| parent | f78ee6afc094cdfd6162bfd645836e84875dcddf (diff) | |
| download | emacs-a9c1b612eb2a05d7a3aed3d7fb1dc589c47a6998.tar.gz emacs-a9c1b612eb2a05d7a3aed3d7fb1dc589c47a6998.zip | |
upstream
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 8 | ||||
| -rw-r--r-- | src/xdisp.c | 16 |
2 files changed, 19 insertions, 5 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 5905c667852..88352c201b6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2012-11-13 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * xdisp.c (decode_mode_spec): Limit the value of WIDTH argument | ||
| 4 | passed to pint2str and pint2hrstr to be at most the size of the | ||
| 5 | frame's decode_mode_spec_buffer. This avoids crashes with very | ||
| 6 | large values of FIELD_WIDTH argument to decode_mode_spec. | ||
| 7 | (Bug#12867) | ||
| 8 | |||
| 1 | 2012-11-13 Paul Eggert <eggert@cs.ucla.edu> | 9 | 2012-11-13 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 10 | ||
| 3 | Fix a race with verify-visited-file-modtime (Bug#12863). | 11 | Fix a race with verify-visited-file-modtime (Bug#12863). |
diff --git a/src/xdisp.c b/src/xdisp.c index 67491c681b7..679b51b0d7d 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -21476,6 +21476,12 @@ decode_mode_spec (struct window *w, register int c, int field_width, | |||
| 21476 | Lisp_Object obj; | 21476 | Lisp_Object obj; |
| 21477 | struct frame *f = XFRAME (WINDOW_FRAME (w)); | 21477 | struct frame *f = XFRAME (WINDOW_FRAME (w)); |
| 21478 | char *decode_mode_spec_buf = f->decode_mode_spec_buffer; | 21478 | char *decode_mode_spec_buf = f->decode_mode_spec_buffer; |
| 21479 | /* We are going to use f->decode_mode_spec_buffer as the buffer to | ||
| 21480 | produce strings from numerical values, so limit preposterously | ||
| 21481 | large values of FIELD_WIDTH to avoid overrunning the buffer's | ||
| 21482 | end. The size of the buffer is enough for FRAME_MESSAGE_BUF_SIZE | ||
| 21483 | bytes plus the terminating null. */ | ||
| 21484 | int width = min (field_width, FRAME_MESSAGE_BUF_SIZE (f)); | ||
| 21479 | struct buffer *b = current_buffer; | 21485 | struct buffer *b = current_buffer; |
| 21480 | 21486 | ||
| 21481 | obj = Qnil; | 21487 | obj = Qnil; |
| @@ -21571,7 +21577,7 @@ decode_mode_spec (struct window *w, register int c, int field_width, | |||
| 21571 | { | 21577 | { |
| 21572 | ptrdiff_t col = current_column (); | 21578 | ptrdiff_t col = current_column (); |
| 21573 | wset_column_number_displayed (w, make_number (col)); | 21579 | wset_column_number_displayed (w, make_number (col)); |
| 21574 | pint2str (decode_mode_spec_buf, field_width, col); | 21580 | pint2str (decode_mode_spec_buf, width, col); |
| 21575 | return decode_mode_spec_buf; | 21581 | return decode_mode_spec_buf; |
| 21576 | } | 21582 | } |
| 21577 | 21583 | ||
| @@ -21602,14 +21608,14 @@ decode_mode_spec (struct window *w, register int c, int field_width, | |||
| 21602 | case 'i': | 21608 | case 'i': |
| 21603 | { | 21609 | { |
| 21604 | ptrdiff_t size = ZV - BEGV; | 21610 | ptrdiff_t size = ZV - BEGV; |
| 21605 | pint2str (decode_mode_spec_buf, field_width, size); | 21611 | pint2str (decode_mode_spec_buf, width, size); |
| 21606 | return decode_mode_spec_buf; | 21612 | return decode_mode_spec_buf; |
| 21607 | } | 21613 | } |
| 21608 | 21614 | ||
| 21609 | case 'I': | 21615 | case 'I': |
| 21610 | { | 21616 | { |
| 21611 | ptrdiff_t size = ZV - BEGV; | 21617 | ptrdiff_t size = ZV - BEGV; |
| 21612 | pint2hrstr (decode_mode_spec_buf, field_width, size); | 21618 | pint2hrstr (decode_mode_spec_buf, width, size); |
| 21613 | return decode_mode_spec_buf; | 21619 | return decode_mode_spec_buf; |
| 21614 | } | 21620 | } |
| 21615 | 21621 | ||
| @@ -21716,12 +21722,12 @@ decode_mode_spec (struct window *w, register int c, int field_width, | |||
| 21716 | line_number_displayed = 1; | 21722 | line_number_displayed = 1; |
| 21717 | 21723 | ||
| 21718 | /* Make the string to show. */ | 21724 | /* Make the string to show. */ |
| 21719 | pint2str (decode_mode_spec_buf, field_width, topline + nlines); | 21725 | pint2str (decode_mode_spec_buf, width, topline + nlines); |
| 21720 | return decode_mode_spec_buf; | 21726 | return decode_mode_spec_buf; |
| 21721 | no_value: | 21727 | no_value: |
| 21722 | { | 21728 | { |
| 21723 | char* p = decode_mode_spec_buf; | 21729 | char* p = decode_mode_spec_buf; |
| 21724 | int pad = field_width - 2; | 21730 | int pad = width - 2; |
| 21725 | while (pad-- > 0) | 21731 | while (pad-- > 0) |
| 21726 | *p++ = ' '; | 21732 | *p++ = ' '; |
| 21727 | *p++ = '?'; | 21733 | *p++ = '?'; |