aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2011-08-29 08:53:21 -0700
committerPaul Eggert2011-08-29 08:53:21 -0700
commit33ef5c64373c744c6ce4329fe021c3eb729aeee4 (patch)
treea776eaca91418d9380cb1d6e004dd0dbf2868df2 /src
parent9d1df220c5484374901f8edff05e41bb575c0c77 (diff)
downloademacs-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.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog4
-rw-r--r--src/editfns.c5
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
292011-08-26 Paul Eggert <eggert@cs.ucla.edu> 332011-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 }