diff options
| author | Paul Eggert | 2011-07-28 14:37:15 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-07-28 14:37:15 -0700 |
| commit | c9f8d652ab67b148cd0a1cb375b0e51e673c4094 (patch) | |
| tree | 28db7746cd8179674ff925067cfde9e38a822799 /src | |
| parent | 3d0c92a26bb73fdc542e4d9e467b31fd0ad02417 (diff) | |
| download | emacs-c9f8d652ab67b148cd0a1cb375b0e51e673c4094.tar.gz emacs-c9f8d652ab67b148cd0a1cb375b0e51e673c4094.zip | |
* editfns.c: Integer and memory overflow fixes.
(set_time_zone_rule): Don't assume environment length fits in int.
(message_length): Now ptrdiff_t, not int.
(Fmessage_box): Don't update size until allocation succeeds.
Don't assume message length fits in int.
(Fformat): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t will do.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 7 | ||||
| -rw-r--r-- | src/editfns.c | 8 |
2 files changed, 11 insertions, 4 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 6cf9a1f8622..b823dd54498 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,12 @@ | |||
| 1 | 2011-07-28 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2011-07-28 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | * editfns.c: Integer and memory overflow fixes. | ||
| 4 | (set_time_zone_rule): Don't assume environment length fits in int. | ||
| 5 | (message_length): Now ptrdiff_t, not int. | ||
| 6 | (Fmessage_box): Don't update size until allocation succeeds. | ||
| 7 | Don't assume message length fits in int. | ||
| 8 | (Fformat): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t will do. | ||
| 9 | |||
| 3 | * doc.c: Integer and memory overflow fixes. | 10 | * doc.c: Integer and memory overflow fixes. |
| 4 | (get_doc_string_buffer_size): Now ptrdiff_t, not int. | 11 | (get_doc_string_buffer_size): Now ptrdiff_t, not int. |
| 5 | (get_doc_string): Check for size calculation overflow. | 12 | (get_doc_string): Check for size calculation overflow. |
diff --git a/src/editfns.c b/src/editfns.c index 18fefa5e3b5..1616305faa3 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -2105,7 +2105,7 @@ static char set_time_zone_rule_tz2[] = "TZ=GMT+1"; | |||
| 2105 | void | 2105 | void |
| 2106 | set_time_zone_rule (const char *tzstring) | 2106 | set_time_zone_rule (const char *tzstring) |
| 2107 | { | 2107 | { |
| 2108 | int envptrs; | 2108 | ptrdiff_t envptrs; |
| 2109 | char **from, **to, **newenv; | 2109 | char **from, **to, **newenv; |
| 2110 | 2110 | ||
| 2111 | /* Make the ENVIRON vector longer with room for TZSTRING. */ | 2111 | /* Make the ENVIRON vector longer with room for TZSTRING. */ |
| @@ -3355,7 +3355,7 @@ usage: (save-restriction &rest BODY) */) | |||
| 3355 | static char *message_text; | 3355 | static char *message_text; |
| 3356 | 3356 | ||
| 3357 | /* Allocated length of that buffer. */ | 3357 | /* Allocated length of that buffer. */ |
| 3358 | static int message_length; | 3358 | static ptrdiff_t message_length; |
| 3359 | 3359 | ||
| 3360 | DEFUN ("message", Fmessage, Smessage, 1, MANY, 0, | 3360 | DEFUN ("message", Fmessage, Smessage, 1, MANY, 0, |
| 3361 | doc: /* Display a message at the bottom of the screen. | 3361 | doc: /* Display a message at the bottom of the screen. |
| @@ -3437,8 +3437,8 @@ usage: (message-box FORMAT-STRING &rest ARGS) */) | |||
| 3437 | } | 3437 | } |
| 3438 | if (SBYTES (val) > message_length) | 3438 | if (SBYTES (val) > message_length) |
| 3439 | { | 3439 | { |
| 3440 | message_text = (char *) xrealloc (message_text, SBYTES (val)); | ||
| 3440 | message_length = SBYTES (val); | 3441 | message_length = SBYTES (val); |
| 3441 | message_text = (char *)xrealloc (message_text, message_length); | ||
| 3442 | } | 3442 | } |
| 3443 | memcpy (message_text, SDATA (val), SBYTES (val)); | 3443 | memcpy (message_text, SDATA (val), SBYTES (val)); |
| 3444 | message2 (message_text, SBYTES (val), | 3444 | message2 (message_text, SBYTES (val), |
| @@ -4163,7 +4163,7 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 4163 | character. CONVBYTES says how much room is needed. Allocate | 4163 | character. CONVBYTES says how much room is needed. Allocate |
| 4164 | enough room (and then some) and do it again. */ | 4164 | enough room (and then some) and do it again. */ |
| 4165 | { | 4165 | { |
| 4166 | EMACS_INT used = p - buf; | 4166 | ptrdiff_t used = p - buf; |
| 4167 | 4167 | ||
| 4168 | if (max_bufsize - used < convbytes) | 4168 | if (max_bufsize - used < convbytes) |
| 4169 | string_overflow (); | 4169 | string_overflow (); |