diff options
| author | Paul Eggert | 2011-08-29 08:53:21 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-08-29 08:53:21 -0700 |
| commit | 33ef5c64373c744c6ce4329fe021c3eb729aeee4 (patch) | |
| tree | a776eaca91418d9380cb1d6e004dd0dbf2868df2 | |
| parent | 9d1df220c5484374901f8edff05e41bb575c0c77 (diff) | |
| download | emacs-33ef5c64373c744c6ce4329fe021c3eb729aeee4.tar.gz emacs-33ef5c64373c744c6ce4329fe021c3eb729aeee4.zip | |
* editfns.c (Fcurrent_time_zone): Don't overrun buffer
even if the time zone offset is outlandishly large.
Don't mishandle offset == INT_MIN.
| -rw-r--r-- | src/ChangeLog | 4 | ||||
| -rw-r--r-- | src/editfns.c | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 4336d6a6b83..afd78a46c6e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -26,6 +26,10 @@ | |||
| 26 | * dispnew.c (add_window_display_history): Don't overrun buffer. | 26 | * dispnew.c (add_window_display_history): Don't overrun buffer. |
| 27 | Truncate instead; this is OK since it's just a log. | 27 | Truncate instead; this is OK since it's just a log. |
| 28 | 28 | ||
| 29 | * editfns.c (Fcurrent_time_zone): Don't overrun buffer | ||
| 30 | even if the time zone offset is outlandishly large. | ||
| 31 | Don't mishandle offset == INT_MIN. | ||
| 32 | |||
| 29 | 2011-08-26 Paul Eggert <eggert@cs.ucla.edu> | 33 | 2011-08-26 Paul Eggert <eggert@cs.ucla.edu> |
| 30 | 34 | ||
| 31 | Integer and memory overflow issues (Bug#9196). | 35 | Integer and memory overflow issues (Bug#9196). |
diff --git a/src/editfns.c b/src/editfns.c index 6759016766f..580298c6e7d 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -2014,7 +2014,7 @@ the data it can't find. */) | |||
| 2014 | { | 2014 | { |
| 2015 | int offset = tm_diff (t, &gmt); | 2015 | int offset = tm_diff (t, &gmt); |
| 2016 | char *s = 0; | 2016 | char *s = 0; |
| 2017 | char buf[6]; | 2017 | char buf[sizeof "+00" + INT_STRLEN_BOUND (int)]; |
| 2018 | 2018 | ||
| 2019 | #ifdef HAVE_TM_ZONE | 2019 | #ifdef HAVE_TM_ZONE |
| 2020 | if (t->tm_zone) | 2020 | if (t->tm_zone) |
| @@ -2029,7 +2029,8 @@ the data it can't find. */) | |||
| 2029 | if (!s) | 2029 | if (!s) |
| 2030 | { | 2030 | { |
| 2031 | /* No local time zone name is available; use "+-NNNN" instead. */ | 2031 | /* No local time zone name is available; use "+-NNNN" instead. */ |
| 2032 | int am = (offset < 0 ? -offset : offset) / 60; | 2032 | int m = offset / 60; |
| 2033 | int am = offset < 0 ? - m : m; | ||
| 2033 | sprintf (buf, "%c%02d%02d", (offset < 0 ? '-' : '+'), am/60, am%60); | 2034 | sprintf (buf, "%c%02d%02d", (offset < 0 ? '-' : '+'), am/60, am%60); |
| 2034 | s = buf; | 2035 | s = buf; |
| 2035 | } | 2036 | } |