mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-01 03:36:03 +00:00
lib: additional patch for 496e83a
Fixes a couple off-by-ones introduced in previous commit. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
parent
eb3d20d398
commit
d1e4a518e6
19
lib/vty.c
19
lib/vty.c
@ -515,7 +515,7 @@ vty_self_insert (struct vty *vty, char c)
|
|||||||
int i;
|
int i;
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
if (vty->length + 1 > VTY_BUFSIZ)
|
if (vty->length + 1 >= VTY_BUFSIZ)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
length = vty->length - vty->cp;
|
length = vty->length - vty->cp;
|
||||||
@ -528,6 +528,8 @@ vty_self_insert (struct vty *vty, char c)
|
|||||||
|
|
||||||
vty->cp++;
|
vty->cp++;
|
||||||
vty->length++;
|
vty->length++;
|
||||||
|
|
||||||
|
vty->buf[vty->length] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Self insert character 'c' in overwrite mode. */
|
/* Self insert character 'c' in overwrite mode. */
|
||||||
@ -553,11 +555,15 @@ vty_self_insert_overwrite (struct vty *vty, char c)
|
|||||||
static void
|
static void
|
||||||
vty_insert_word_overwrite (struct vty *vty, char *str)
|
vty_insert_word_overwrite (struct vty *vty, char *str)
|
||||||
{
|
{
|
||||||
size_t nwrite = MIN ((int) strlen (str), VTY_BUFSIZ - vty->cp);
|
if (vty->cp == VTY_BUFSIZ)
|
||||||
vty_write (vty, str, nwrite);
|
return;
|
||||||
strncpy (&vty->buf[vty->cp], str, nwrite);
|
|
||||||
|
size_t nwrite = MIN ((int) strlen (str), VTY_BUFSIZ - vty->cp - 1);
|
||||||
|
memcpy (&vty->buf[vty->cp], str, nwrite);
|
||||||
vty->cp += nwrite;
|
vty->cp += nwrite;
|
||||||
vty->length = vty->cp;
|
vty->length = MAX (vty->cp, vty->length);
|
||||||
|
vty->buf[vty->length] = '\0';
|
||||||
|
vty_write (vty, str, nwrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Forward character. */
|
/* Forward character. */
|
||||||
@ -614,6 +620,7 @@ vty_history_print (struct vty *vty)
|
|||||||
length = strlen (vty->hist[vty->hp]);
|
length = strlen (vty->hist[vty->hp]);
|
||||||
memcpy (vty->buf, vty->hist[vty->hp], length);
|
memcpy (vty->buf, vty->hist[vty->hp], length);
|
||||||
vty->cp = vty->length = length;
|
vty->cp = vty->length = length;
|
||||||
|
vty->buf[vty->length] = '\0';
|
||||||
|
|
||||||
/* Redraw current line */
|
/* Redraw current line */
|
||||||
vty_redraw_line (vty);
|
vty_redraw_line (vty);
|
||||||
@ -2141,7 +2148,7 @@ vtysh_read (struct thread *thread)
|
|||||||
printf ("line: %.*s\n", nbytes, buf);
|
printf ("line: %.*s\n", nbytes, buf);
|
||||||
#endif /* VTYSH_DEBUG */
|
#endif /* VTYSH_DEBUG */
|
||||||
|
|
||||||
if (vty->length + nbytes > VTY_BUFSIZ)
|
if (vty->length + nbytes >= VTY_BUFSIZ)
|
||||||
{
|
{
|
||||||
/* Clear command line buffer. */
|
/* Clear command line buffer. */
|
||||||
vty->cp = vty->length = 0;
|
vty->cp = vty->length = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user