diff options
| author | Richard M. Stallman | 1995-11-27 03:03:33 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-11-27 03:03:33 +0000 |
| commit | 3c7d31b921c1f532f0c2ff6b97a1cb9c93617dbf (patch) | |
| tree | a1eefc2533e4ff974382e91482df10cdb2860def /src | |
| parent | 62555c22ca24836f41a0973236cfd0f83b4d5532 (diff) | |
| download | emacs-3c7d31b921c1f532f0c2ff6b97a1cb9c93617dbf.tar.gz emacs-3c7d31b921c1f532f0c2ff6b97a1cb9c93617dbf.zip | |
(decode_mode_spec): For p and P, avoid overflow with large buffer sizes.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index a1b5a2ea88f..86836714dcf 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -3790,7 +3790,11 @@ decode_mode_spec (w, c, spec_width, maxwidth) | |||
| 3790 | return "Top"; | 3790 | return "Top"; |
| 3791 | else | 3791 | else |
| 3792 | { | 3792 | { |
| 3793 | total = ((pos - BUF_BEGV (b)) * 100 + total - 1) / total; | 3793 | if (total > 1000000) |
| 3794 | /* Do it differently for a large value, to avoid overflow. */ | ||
| 3795 | total = ((pos - BUF_BEGV (b)) + (total / 100) - 1) / (total / 100); | ||
| 3796 | else | ||
| 3797 | total = ((pos - BUF_BEGV (b)) * 100 + total - 1) / total; | ||
| 3794 | /* We can't normally display a 3-digit number, | 3798 | /* We can't normally display a 3-digit number, |
| 3795 | so get us a 2-digit number that is close. */ | 3799 | so get us a 2-digit number that is close. */ |
| 3796 | if (total == 100) | 3800 | if (total == 100) |
| @@ -3816,7 +3820,11 @@ decode_mode_spec (w, c, spec_width, maxwidth) | |||
| 3816 | } | 3820 | } |
| 3817 | else | 3821 | else |
| 3818 | { | 3822 | { |
| 3819 | total = ((botpos - BUF_BEGV (b)) * 100 + total - 1) / total; | 3823 | if (total > 1000000) |
| 3824 | /* Do it differently for a large value, to avoid overflow. */ | ||
| 3825 | total = ((botpos - BUF_BEGV (b)) + (total / 100) - 1) / (total / 100); | ||
| 3826 | else | ||
| 3827 | total = ((botpos - BUF_BEGV (b)) * 100 + total - 1) / total; | ||
| 3820 | /* We can't normally display a 3-digit number, | 3828 | /* We can't normally display a 3-digit number, |
| 3821 | so get us a 2-digit number that is close. */ | 3829 | so get us a 2-digit number that is close. */ |
| 3822 | if (total == 100) | 3830 | if (total == 100) |