[lldp-devel] [PATCH] vdptest connect to lldpad broken

Thomas Richter tmricht at linux.vnet.ibm.com
Thu Feb 7 13:23:54 UTC 2013


With the removal of the /var/run/lldpad.pid file, vdptest
connects to lldpad via the liblldp_clif.so library.
It sends a ping command to llpdad and expects a pongXXXXX
reply back, with XXXXX being lldpad process identifer.
The parsing of the reply fails, it is prepended by some
characters. Also the reply string is not null terminated
and might have trailing characters.

Signed-off-by: Thomas Richter <tmricht at linux.vnet.ibm.com>
---
 test/vdptest.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/test/vdptest.c b/test/vdptest.c
index e8d68a8..6646485 100644
--- a/test/vdptest.c
+++ b/test/vdptest.c
@@ -673,6 +673,7 @@ static void lldpad_pid(void)
 	char buf[MAX_CLIF_MSGBUF];
 	size_t len;
 	int ret;
+	char *ppong;
 
 	clif_conn = clif_open();
 	if (!clif_conn) {
@@ -693,7 +694,9 @@ static void lldpad_pid(void)
 		fprintf(stderr, "%s: ping command failed\n", progname);
 		exit(4);
 	}
-	if (sscanf(buf, "PPONG%d", &lldpad) != 1) {
+	buf[len] = '\0';
+	ppong = strstr(buf, "PPONG");		/* Ignore leading chars */
+	if (!ppong || sscanf(ppong, "PPONG%d", &lldpad) != 1) {
 		fprintf(stderr, "%s error parsing pid of lldpad\n",
 			progname);
 		exit(5);
-- 
1.7.1



More information about the lldp-devel mailing list