mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-08 03:28:31 +00:00
2004-09-17 Paul Jakma <paul@dishone.st>
* vtysh.c: (vtysh_client_execute) trailling NULLs can be arbitrarily split across reads, dont get confused by this and block forever.
This commit is contained in:
parent
90f0c88123
commit
2852de1c90
@ -1,3 +1,8 @@
|
|||||||
|
2004-09-17 Paul Jakma <paul@dishone.st>
|
||||||
|
|
||||||
|
* vtysh.c: (vtysh_client_execute) trailling NULLs can be arbitrarily
|
||||||
|
split across reads, dont get confused by this and block forever.
|
||||||
|
|
||||||
2004-09-13 Paul Jakma <paul@dishone.st>
|
2004-09-13 Paul Jakma <paul@dishone.st>
|
||||||
|
|
||||||
* Makefile.am: extract.pl isnt in srcdir, it's always in the builddir.
|
* Makefile.am: extract.pl isnt in srcdir, it's always in the builddir.
|
||||||
|
@ -161,6 +161,7 @@ vtysh_client_execute (struct vtysh_client *vclient, char *line, FILE *fp)
|
|||||||
char buf[1001];
|
char buf[1001];
|
||||||
int nbytes;
|
int nbytes;
|
||||||
int i;
|
int i;
|
||||||
|
int numnulls = 0;
|
||||||
|
|
||||||
if (vclient->fd < 0)
|
if (vclient->fd < 0)
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
@ -188,15 +189,29 @@ vtysh_client_execute (struct vtysh_client *vclient, char *line, FILE *fp)
|
|||||||
fprintf (fp, "%s", buf);
|
fprintf (fp, "%s", buf);
|
||||||
fflush (fp);
|
fflush (fp);
|
||||||
|
|
||||||
|
/* check for trailling \0\0\0\0, even if split across reads */
|
||||||
if (nbytes >= 4)
|
if (nbytes >= 4)
|
||||||
{
|
{
|
||||||
i = nbytes-4;
|
i = nbytes-4;
|
||||||
if (buf[i] == '\0' && buf[i + 1] == '\0' && buf[i + 2] == '\0')
|
numnulls = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
while (i < nbytes)
|
||||||
{
|
{
|
||||||
ret = buf[i + 3];
|
if (buf[i++] == '\0')
|
||||||
|
numnulls++;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
numnulls = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* got 3 or more trailling nulls? */
|
||||||
|
if (numnulls >= 3)
|
||||||
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user