summaryrefslogtreecommitdiff
path: root/src/minibuf.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2011-08-29 08:43:34 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2011-08-29 08:43:34 -0700
commit62f19c197d32e8773a284616d575686d87903b7d (patch)
tree237de2d21e8a33f6821248890c01de7d83dbcba4 /src/minibuf.c
parent005d87bd2306e943a16b86c36d1482651d9932d8 (diff)
downloademacs-62f19c197d32e8773a284616d575686d87903b7d.tar.gz
sprintf-related integer and memory overflow issues.
* doprnt.c (doprnt): Support printing ptrdiff_t and intmax_t values. (esprintf, esnprintf, exprintf, evxprintf): New functions. * keyboard.c (command_loop_level): Now EMACS_INT, not int. (cmd_error): kbd macro iterations count is now EMACS_INT, not int. (modify_event_symbol): Do not assume that the length of name_alist_or_stem is safe to alloca and fits in int. (Fexecute_extended_command): Likewise for function name and binding. (Frecursion_depth): Wrap around reliably on integer overflow. * keymap.c (push_key_description): First arg is now EMACS_INT, not int, since some callers pass EMACS_INT values. (Fsingle_key_description): Don't crash if symbol name contains more than MAX_ALLOCA bytes. * minibuf.c (minibuf_level): Now EMACS_INT, not int. (get_minibuffer): Arg is now EMACS_INT, not int. * lisp.h (get_minibuffer, push_key_description): Reflect API changes. (esprintf, esnprintf, exprintf, evxprintf): New decls. * window.h (command_loop_level, minibuf_level): Reflect API changes.
Diffstat (limited to 'src/minibuf.c')
-rw-r--r--src/minibuf.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/minibuf.c b/src/minibuf.c
index eb564a10ec6..ad8f3ed8b86 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -49,7 +49,7 @@ static Lisp_Object minibuf_save_list;
/* Depth in minibuffer invocations. */
-int minibuf_level;
+EMACS_INT minibuf_level;
/* The maximum length of a minibuffer history. */
@@ -772,10 +772,10 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
used for nonrecursive minibuffer invocations. */
Lisp_Object
-get_minibuffer (int depth)
+get_minibuffer (EMACS_INT depth)
{
Lisp_Object tail, num, buf;
- char name[24];
+ char name[sizeof " *Minibuf-*" + INT_STRLEN_BOUND (EMACS_INT)];
XSETFASTINT (num, depth);
tail = Fnthcdr (num, Vminibuffer_list);
@@ -787,7 +787,7 @@ get_minibuffer (int depth)
buf = Fcar (tail);
if (NILP (buf) || NILP (BVAR (XBUFFER (buf), name)))
{
- sprintf (name, " *Minibuf-%d*", depth);
+ sprintf (name, " *Minibuf-%"pI"d*", depth);
buf = Fget_buffer_create (build_string (name));
/* Although the buffer's name starts with a space, undo should be