From dbc46ca401fc010fd105c1ebc32a2896ae234253 Mon Sep 17 00:00:00 2001 From: Brian Somers Date: Sat, 22 Jun 2002 21:01:47 +0000 Subject: [PATCH] Don't expect NUL terminated data in all netgraph messages received. Only display message hook values we understand. --- usr.sbin/ppp/ether.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/usr.sbin/ppp/ether.c b/usr.sbin/ppp/ether.c index 9c3f752ae1f2..062121609ce2 100644 --- a/usr.sbin/ppp/ether.c +++ b/usr.sbin/ppp/ether.c @@ -221,7 +221,7 @@ ether_MessageIn(struct etherdevice *dev) struct timeval t; fd_set *r; u_long slot; - int ret; + int asciilen, ret; if (dev->cs < 0) return; @@ -254,6 +254,7 @@ ether_MessageIn(struct etherdevice *dev) return; } + asciilen = 0; switch (rep->header.cmd) { case NGM_PPPOE_SET_FLAG: msg = "SET_FLAG"; break; case NGM_PPPOE_CONNECT: msg = "CONNECT"; break; @@ -267,6 +268,7 @@ ether_MessageIn(struct etherdevice *dev) msg = "ACNAME"; if (setenv("ACNAME", sts->hook, 1) != 0) log_Printf(LogWARN, "setenv: cannot set ACNAME=%s: %m", sts->hook); + asciilen = rep->header.arglen; break; case NGM_PPPOE_SESSIONID: msg = "SESSIONID"; @@ -285,7 +287,11 @@ ether_MessageIn(struct etherdevice *dev) break; } - log_Printf(LogPHASE, "Received NGM_PPPOE_%s (hook \"%s\")\n", msg, sts->hook); + if (asciilen) + log_Printf(LogPHASE, "Received NGM_PPPOE_%s (hook \"%.*s\")\n", + msg, asciilen, sts->hook); + else + log_Printf(LogPHASE, "Received NGM_PPPOE_%s\n", msg); switch (rep->header.cmd) { case NGM_PPPOE_SUCCESS: