diff options
| author | Paul Eggert | 2011-07-04 00:44:38 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-07-04 00:44:38 -0700 |
| commit | da64016efd7b728fa840ac01acef1456197850e0 (patch) | |
| tree | 655c2bf885fcbe9ebb3b00edea1310ed219798ba /src | |
| parent | 8db5f6627827ad5b230a9f8e2ca92815793c7d5a (diff) | |
| download | emacs-da64016efd7b728fa840ac01acef1456197850e0.tar.gz emacs-da64016efd7b728fa840ac01acef1456197850e0.zip | |
* editfns.c (Fformat_time_string): Don't assume strlen fits in int.
Report string overflow if the output is too long.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/editfns.c | 10 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index f861e8ed5f7..4ea54141142 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2011-07-04 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | * editfns.c (Fformat_time_string): Don't assume strlen fits in int. | ||
| 4 | Report string overflow if the output is too long. | ||
| 5 | |||
| 1 | 2011-07-04 Juanma Barranquero <lekktu@gmail.com> | 6 | 2011-07-04 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 7 | ||
| 3 | * gnutls.c (Fgnutls_boot): Don't mention :verify-error. | 8 | * gnutls.c (Fgnutls_boot): Don't mention :verify-error. |
diff --git a/src/editfns.c b/src/editfns.c index c470c9be985..bb36d0dee71 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -1700,7 +1700,7 @@ For example, to produce full ISO 8601 format, use "%Y-%m-%dT%T%z". */) | |||
| 1700 | (Lisp_Object format_string, Lisp_Object timeval, Lisp_Object universal) | 1700 | (Lisp_Object format_string, Lisp_Object timeval, Lisp_Object universal) |
| 1701 | { | 1701 | { |
| 1702 | time_t value; | 1702 | time_t value; |
| 1703 | int size; | 1703 | ptrdiff_t size; |
| 1704 | int usec; | 1704 | int usec; |
| 1705 | int ns; | 1705 | int ns; |
| 1706 | struct tm *tm; | 1706 | struct tm *tm; |
| @@ -1717,7 +1717,9 @@ For example, to produce full ISO 8601 format, use "%Y-%m-%dT%T%z". */) | |||
| 1717 | Vlocale_coding_system, 1); | 1717 | Vlocale_coding_system, 1); |
| 1718 | 1718 | ||
| 1719 | /* This is probably enough. */ | 1719 | /* This is probably enough. */ |
| 1720 | size = SBYTES (format_string) * 6 + 50; | 1720 | size = SBYTES (format_string); |
| 1721 | if (size <= (STRING_BYTES_BOUND - 50) / 6) | ||
| 1722 | size = size * 6 + 50; | ||
| 1721 | 1723 | ||
| 1722 | BLOCK_INPUT; | 1724 | BLOCK_INPUT; |
| 1723 | tm = ut ? gmtime (&value) : localtime (&value); | 1725 | tm = ut ? gmtime (&value) : localtime (&value); |
| @@ -1730,7 +1732,7 @@ For example, to produce full ISO 8601 format, use "%Y-%m-%dT%T%z". */) | |||
| 1730 | while (1) | 1732 | while (1) |
| 1731 | { | 1733 | { |
| 1732 | char *buf = (char *) alloca (size + 1); | 1734 | char *buf = (char *) alloca (size + 1); |
| 1733 | int result; | 1735 | size_t result; |
| 1734 | 1736 | ||
| 1735 | buf[0] = '\1'; | 1737 | buf[0] = '\1'; |
| 1736 | BLOCK_INPUT; | 1738 | BLOCK_INPUT; |
| @@ -1749,6 +1751,8 @@ For example, to produce full ISO 8601 format, use "%Y-%m-%dT%T%z". */) | |||
| 1749 | SBYTES (format_string), | 1751 | SBYTES (format_string), |
| 1750 | tm, ut, ns); | 1752 | tm, ut, ns); |
| 1751 | UNBLOCK_INPUT; | 1753 | UNBLOCK_INPUT; |
| 1754 | if (STRING_BYTES_BOUND <= result) | ||
| 1755 | string_overflow (); | ||
| 1752 | size = result + 1; | 1756 | size = result + 1; |
| 1753 | } | 1757 | } |
| 1754 | } | 1758 | } |