summaryrefslogtreecommitdiff
path: root/gnu/lib/libreadline/isearch.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/isearch.c
parent762627a92975f83878f76ab532715c2a26899234 (diff)
strings
ok tedu@, art@
Diffstat (limited to 'gnu/lib/libreadline/isearch.c')
-rw-r--r--gnu/lib/libreadline/isearch.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/gnu/lib/libreadline/isearch.c b/gnu/lib/libreadline/isearch.c
index 952c10ddf8e..be051203335 100644
--- a/gnu/lib/libreadline/isearch.c
+++ b/gnu/lib/libreadline/isearch.c
@@ -93,17 +93,18 @@ rl_display_search (search_string, reverse_p, where)
int reverse_p, where;
{
char *message;
- int msglen, searchlen;
+ int msglen, searchlen, mlen;
searchlen = (search_string && *search_string) ? strlen (search_string) : 0;
- message = xmalloc (searchlen + 33);
+ mlen = searchlen + 33;
+ message = xmalloc (mlen);
msglen = 0;
#if defined (NOTDEF)
if (where != -1)
{
- sprintf (message, "[%d]", where + history_base);
+ snprintf (message, mlen, "[%d]", where + history_base);
msglen = strlen (message);
}
#endif /* NOTDEF */
@@ -112,20 +113,17 @@ rl_display_search (search_string, reverse_p, where)
if (reverse_p)
{
- strcpy (message + msglen, "reverse-");
- msglen += 8;
+ strlcat (message, "reverse-", mlen);
}
- strcpy (message + msglen, "i-search)`");
- msglen += 10;
+ strlcat (message, "i-search)`", mlen);
if (search_string)
{
- strcpy (message + msglen, search_string);
- msglen += searchlen;
+ strlcat (message, search_string, mlen);
}
- strcpy (message + msglen, "': ");
+ strlcat (message, "': ", mlen);
rl_message ("%s", message, 0);
free (message);
@@ -202,8 +200,9 @@ rl_search_history (direction, invoking_key)
else
{
/* Keep track of this so we can free it. */
- allocated_line = xmalloc (1 + strlen (rl_line_buffer));
- strcpy (allocated_line, &rl_line_buffer[0]);
+ allocated_line = strdup(rl_line_buffer);
+ if (allocated_line == NULL)
+ memory_error_and_abort("strdup");
lines[i] = allocated_line;
}
@@ -297,7 +296,7 @@ rl_search_history (direction, invoking_key)
break;
case CTRL ('G'):
- strcpy (rl_line_buffer, lines[orig_line]);
+ strlcpy (rl_line_buffer, lines[orig_line], rl_line_buffer_len);
rl_point = orig_point;
rl_end = strlen (rl_line_buffer);
rl_restore_prompt();
@@ -402,7 +401,7 @@ rl_search_history (direction, invoking_key)
if (line_len >= rl_line_buffer_len)
rl_extend_line_buffer (line_len);
- strcpy (rl_line_buffer, lines[i]);
+ strlcpy (rl_line_buffer, lines[i], rl_line_buffer_len);
rl_point = line_index;
rl_end = line_len;
last_found_line = i;
@@ -416,7 +415,7 @@ rl_search_history (direction, invoking_key)
not found. We use this to determine where to place rl_point. */
/* First put back the original state. */
- strcpy (rl_line_buffer, lines[orig_line]);
+ strlcpy (rl_line_buffer, lines[orig_line], rl_line_buffer_len);
rl_restore_prompt ();