]> git.puffer.fish Git - mirror/frr.git/commitdiff
2004-11-11 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
authorajs <ajs>
Thu, 11 Nov 2004 14:03:39 +0000 (14:03 +0000)
committerajs <ajs>
Thu, 11 Nov 2004 14:03:39 +0000 (14:03 +0000)
* vtysh.c: (vtysh_client_execute) Fix flaws in detecting trailing
  '\0' chars and command return code.

vtysh/ChangeLog
vtysh/vtysh.c

index ad7e7b2d794e0843c9c14d54f5650e739c59cd03..ea611179f5868efdeb0834b521fbd78990a7a5fb 100644 (file)
@@ -1,3 +1,8 @@
+2004-11-11 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
+
+       * vtysh.c: (vtysh_client_execute) Fix flaws in detecting trailing
+         '\0' chars and command return code.
+
 2004-10-28 Hasso Tepper <hasso at quagga.net>
 
        * vtysh.c: "show running-daemons" broke users habits who are using
index d3f672d325e8f6acc37749751379513f34df459e..c7271ff02d75cabf1167ac7b3642f63687acb9a5 100644 (file)
@@ -191,8 +191,11 @@ vtysh_client_execute (struct vtysh_client *vclient, const char *line, FILE *fp)
 
       if (nbytes > 0)
        {
+         if ((numnulls == 3) && (nbytes == 1))
+           return buf[0];
+
          buf[nbytes] = '\0';
-         fprintf (fp, "%s", buf);
+         fputs (buf, fp);
          fflush (fp);
          
          /* check for trailling \0\0\0<ret code>, 
@@ -212,18 +215,14 @@ vtysh_client_execute (struct vtysh_client *vclient, const char *line, FILE *fp)
               if (buf[i++] == '\0')
                 numnulls++;
               else
-                {
-                  numnulls = 0;
-                  break;
-                }
+                numnulls = 0;
             }
 
-          /* got 3 or more trailling nulls? */
-          if (numnulls >= 3)
+          /* got 3 or more trailing NULs? */
+          if ((numnulls >= 3) && (i < nbytes))
             return (buf[nbytes-1]);
        }
     }
-  assert (1);
 }
 
 void