From: Paul Mackerras Date: Fri, 10 Dec 2021 21:40:57 +0000 (+1100) Subject: pppoe: Print packet fields in hex if they contain non-printable characters X-Git-Tag: ppp-2.5.0~49 X-Git-Url: http://git.ozlabs.org/?a=commitdiff_plain;h=ca75478c3e694d77c8af2fab1409346aafa1d9c5;p=ppp.git pppoe: Print packet fields in hex if they contain non-printable characters This adds logic to pppoe_printpkt to print text fields as hex if the field contains any non-printable characters. This is so that a malicious, buggy or hacked access concentrator can't cause us to send non-printing characters to syslog. Signed-off-by: Paul Mackerras --- diff --git a/pppd/plugins/pppoe/common.c b/pppd/plugins/pppoe/common.c index 8b0e636..9ddbcbd 100644 --- a/pppd/plugins/pppoe/common.c +++ b/pppd/plugins/pppoe/common.c @@ -28,6 +28,7 @@ static char const RCSID[] = #include #include #include /* for LOG_DEBUG */ +#include #ifdef HAVE_UNISTD_H #include @@ -303,6 +304,15 @@ void pppoe_printpkt(PPPoEPacket *packet, printer(arg, "unknown tag 0x%x", tag); } if (tlen) { + /* If it is supposed to be text, make sure it's all printing chars */ + if (text) { + for (j = 0; j < tlen; ++j) { + if (!isprint(packet->payload[i+j])) { + text = 0; + break; + } + } + } if (text) printer(arg, " %.*s", tlen, &packet->payload[i]); else {