summaryrefslogtreecommitdiff
path: root/vtysh/vtysh.c
diff options
context:
space:
mode:
authorpaul <paul>2004-10-11 18:21:55 +0000
committerpaul <paul>2004-10-11 18:21:55 +0000
commit0921d48e8eae1c417a06b8470108ae46584375b5 (patch)
treef5f1007cff529cdc2d641774d8c3e2a020822451 /vtysh/vtysh.c
parentc8a440eca0645a8a78140f83907acce25a3c67c6 (diff)
2004-09-17 Paul Jakma <paul@dishone.st>
* vtysh.c: (vtysh_client_execute) fix the sync fix. The 4th and final sync byte is not ASCII NULL, it's actually a status integer, and only ASCII NULL if CMD_SUCCESS is returned by daemon. Fix pointed out by Hasso.
Diffstat (limited to 'vtysh/vtysh.c')
-rw-r--r--vtysh/vtysh.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index 0df5ddbb..086b5dfe 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -195,7 +195,10 @@ vtysh_client_execute (struct vtysh_client *vclient, const char *line, FILE *fp)
fprintf (fp, "%s", buf);
fflush (fp);
- /* check for trailling \0\0\0\0, even if split across reads */
+ /* check for trailling \0\0\0<ret code>,
+ * even if split across reads
+ * (see lib/vty.c::vtysh_read)
+ */
if (nbytes >= 4)
{
i = nbytes-4;
@@ -204,7 +207,7 @@ vtysh_client_execute (struct vtysh_client *vclient, const char *line, FILE *fp)
else
i = 0;
- while (i < nbytes)
+ while (i < nbytes && numnulls < 3)
{
if (buf[i++] == '\0')
numnulls++;
@@ -217,10 +220,10 @@ vtysh_client_execute (struct vtysh_client *vclient, const char *line, FILE *fp)
/* got 3 or more trailling nulls? */
if (numnulls >= 3)
- return CMD_SUCCESS;
+ return (buf[nbytes-1]);
}
}
- return ret;
+ assert (1);
}
void