diff options
| author | Paul Eggert | 2011-06-05 23:16:12 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-06-05 23:16:12 -0700 |
| commit | d1f3d2afe1057a99b9dec6d1bd5b57bfee81fdff (patch) | |
| tree | f471bdf3143b2d4ba0cf2d4c4e530304b7a67c88 /src/character.c | |
| parent | dd52fcea063f37a9875bf9196dbe11a442e8adfc (diff) | |
| download | emacs-d1f3d2afe1057a99b9dec6d1bd5b57bfee81fdff.tar.gz emacs-d1f3d2afe1057a99b9dec6d1bd5b57bfee81fdff.zip | |
Check for buffer and string overflow more precisely.
* buffer.h (BUF_BYTES_MAX): New macro.
* lisp.h (STRING_BYTES_MAX): New macro.
* alloc.c (Fmake_string):
* character.c (string_escape_byte8):
* coding.c (coding_alloc_by_realloc):
* doprnt.c (doprnt):
* editfns.c (Fformat):
* eval.c (verror):
Use STRING_BYTES_MAX, not MOST_POSITIVE_FIXNUM,
since they may not be the same number.
* editfns.c (Finsert_char):
* fileio.c (Finsert_file_contents):
Likewise for BUF_BYTES_MAX.
Diffstat (limited to 'src/character.c')
| -rw-r--r-- | src/character.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/character.c b/src/character.c index 34e69da9cc5..170952619e7 100644 --- a/src/character.c +++ b/src/character.c | |||
| @@ -838,7 +838,7 @@ string_escape_byte8 (Lisp_Object string) | |||
| 838 | if (multibyte) | 838 | if (multibyte) |
| 839 | { | 839 | { |
| 840 | if ((MOST_POSITIVE_FIXNUM - nchars) / 3 < byte8_count | 840 | if ((MOST_POSITIVE_FIXNUM - nchars) / 3 < byte8_count |
| 841 | || (MOST_POSITIVE_FIXNUM - nbytes) / 2 < byte8_count) | 841 | || (STRING_BYTES_MAX - nbytes) / 2 < byte8_count) |
| 842 | string_overflow (); | 842 | string_overflow (); |
| 843 | 843 | ||
| 844 | /* Convert 2-byte sequence of byte8 chars to 4-byte octal. */ | 844 | /* Convert 2-byte sequence of byte8 chars to 4-byte octal. */ |
| @@ -847,7 +847,7 @@ string_escape_byte8 (Lisp_Object string) | |||
| 847 | } | 847 | } |
| 848 | else | 848 | else |
| 849 | { | 849 | { |
| 850 | if ((MOST_POSITIVE_FIXNUM - nchars) / 3 < byte8_count) | 850 | if ((STRING_BYTES_MAX - nchars) / 3 < byte8_count) |
| 851 | string_overflow (); | 851 | string_overflow (); |
| 852 | 852 | ||
| 853 | /* Convert 1-byte sequence of byte8 chars to 4-byte octal. */ | 853 | /* Convert 1-byte sequence of byte8 chars to 4-byte octal. */ |