diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2011-06-08 10:22:24 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2011-06-08 10:22:24 -0700 |
commit | c9d624c605059127505b6d4baec8f07d6ff731d9 (patch) | |
tree | 6479c3ac48386543ce3985053d117b25e4a75935 /src/doprnt.c | |
parent | 353032ce71627010043aba9d536a3e739894a1d2 (diff) | |
download | emacs-c9d624c605059127505b6d4baec8f07d6ff731d9.tar.gz |
* alloc.c: Catch some string size overflows that we were missing.
(XMALLOC_OVERRUN_CHECK_SIZE) [!XMALLOC_OVERRUN_CHECK]: Define to 0,
for convenience in STRING_BYTES_MAX.
(STRING_BYTES_MAX): New macro, superseding the old one in lisp.h.
The definition here is exact; the one in lisp.h was approximate.
(allocate_string_data): Check for string overflow. This catches
some instances we weren't catching before. Also, it catches
size_t overflow on (unusual) hosts where SIZE_MAX <= min
(PTRDIFF_MAX, MOST_POSITIVE_FIXNUM), e.g., when size_t is 32 bits
and ptrdiff_t and EMACS_INT are both 64 bits.
* character.c, coding.c, doprnt.c, editfns.c, eval.c:
All uses of STRING_BYTES_MAX replaced by STRING_BYTES_BOUND.
* lisp.h (STRING_BYTES_BOUND): Renamed from STRING_BYTES_MAX.
Diffstat (limited to 'src/doprnt.c')
-rw-r--r-- | src/doprnt.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/doprnt.c b/src/doprnt.c index 5ca3ea89be6..f5e31153628 100644 --- a/src/doprnt.c +++ b/src/doprnt.c @@ -329,7 +329,7 @@ doprnt (char *buffer, register size_t bufsize, const char *format, minlen = atoi (&fmtcpy[1]); string = va_arg (ap, char *); tem = strlen (string); - if (tem > STRING_BYTES_MAX) + if (STRING_BYTES_BOUND < tem) error ("String for %%s or %%S format is too long"); width = strwidth (string, tem); goto doit1; @@ -338,7 +338,7 @@ doprnt (char *buffer, register size_t bufsize, const char *format, doit: /* Coming here means STRING contains ASCII only. */ tem = strlen (string); - if (tem > STRING_BYTES_MAX) + if (STRING_BYTES_BOUND < tem) error ("Format width or precision too large"); width = tem; doit1: |