Report string overflow if the output is too long.
+2011-07-04 Paul Eggert <eggert@cs.ucla.edu>
+
+ * editfns.c (Fformat_time_string): Don't assume strlen fits in int.
+ Report string overflow if the output is too long.
+
2011-07-04 Juanma Barranquero <lekktu@gmail.com>
* gnutls.c (Fgnutls_boot): Don't mention :verify-error.
(Lisp_Object format_string, Lisp_Object timeval, Lisp_Object universal)
{
time_t value;
- int size;
+ ptrdiff_t size;
int usec;
int ns;
struct tm *tm;
Vlocale_coding_system, 1);
/* This is probably enough. */
- size = SBYTES (format_string) * 6 + 50;
+ size = SBYTES (format_string);
+ if (size <= (STRING_BYTES_BOUND - 50) / 6)
+ size = size * 6 + 50;
BLOCK_INPUT;
tm = ut ? gmtime (&value) : localtime (&value);
while (1)
{
char *buf = (char *) alloca (size + 1);
- int result;
+ size_t result;
buf[0] = '\1';
BLOCK_INPUT;
SBYTES (format_string),
tm, ut, ns);
UNBLOCK_INPUT;
+ if (STRING_BYTES_BOUND <= result)
+ string_overflow ();
size = result + 1;
}
}