summaryrefslogtreecommitdiff
path: root/gnu/lib/libreadline/bind.c
diff options
context:
space:
mode:
authorBob Beck <beck@cvs.openbsd.org>2003-05-08 05:36:52 +0000
committerBob Beck <beck@cvs.openbsd.org>2003-05-08 05:36:52 +0000
commitb1ca941db1b833d9197edd3f2a2ecd1633bc1d81 (patch)
tree544d1f8821bca7e4b0a7cbba9aca8a71efabb8a3 /gnu/lib/libreadline/bind.c
parent762627a92975f83878f76ab532715c2a26899234 (diff)
strings
ok tedu@, art@
Diffstat (limited to 'gnu/lib/libreadline/bind.c')
-rw-r--r--gnu/lib/libreadline/bind.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/gnu/lib/libreadline/bind.c b/gnu/lib/libreadline/bind.c
index fc6fe284116..d9947c389df 100644
--- a/gnu/lib/libreadline/bind.c
+++ b/gnu/lib/libreadline/bind.c
@@ -1761,14 +1761,15 @@ rl_invoking_keyseqs_in_map (function, map)
for (i = 0; seqs[i]; i++)
{
- char *keyname = (char *)xmalloc (6 + strlen (seqs[i]));
+ int len = 6 + strlen(seqs[i]);
+ char *keyname = (char *)xmalloc (len);
if (key == ESC)
- sprintf (keyname, "\\e");
+ snprintf(keyname, len, "\\e");
else if (CTRL_CHAR (key))
- sprintf (keyname, "\\C-%c", _rl_to_lower (UNCTRL (key)));
+ snprintf(keyname, len, "\\C-%c", _rl_to_lower (UNCTRL (key)));
else if (key == RUBOUT)
- sprintf (keyname, "\\C-?");
+ snprintf(keyname, len, "\\C-?");
else if (key == '\\' || key == '"')
{
keyname[0] = '\\';
@@ -1781,7 +1782,7 @@ rl_invoking_keyseqs_in_map (function, map)
keyname[1] = '\0';
}
- strcat (keyname, seqs[i]);
+ strlcat (keyname, seqs[i], len);
free (seqs[i]);
if (result_index + 2 > result_size)
@@ -1935,9 +1936,10 @@ _rl_macro_dumper_internal (print_readably, map, prefix)
prefix_len = prefix ? strlen (prefix) : 0;
if (key == ESC)
{
- keyname = xmalloc (3 + prefix_len);
+ int len = 3 + prefix_len;
+ keyname = xmalloc (len);
if (prefix)
- strcpy (keyname, prefix);
+ strlcpy (keyname, prefix, len);
keyname[prefix_len] = '\\';
keyname[prefix_len + 1] = 'e';
keyname[prefix_len + 2] = '\0';
@@ -1947,9 +1949,8 @@ _rl_macro_dumper_internal (print_readably, map, prefix)
keyname = _rl_get_keyname (key);
if (prefix)
{
- out = xmalloc (strlen (keyname) + prefix_len + 1);
- strcpy (out, prefix);
- strcpy (out + prefix_len, keyname);
+ if (asprintf(&out, "%s%s", prefix, keyname) == -1)
+ memory_error_and_abort("asprintf");
free (keyname);
keyname = out;
}