]> git.ozlabs.org Git - ppp.git/commitdiff
pppoe: Print packet fields in hex if they contain non-printable characters
authorPaul Mackerras <paulus@ozlabs.org>
Fri, 10 Dec 2021 21:40:57 +0000 (08:40 +1100)
committerPaul Mackerras <paulus@ozlabs.org>
Fri, 10 Dec 2021 21:40:57 +0000 (08:40 +1100)
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 <paulus@ozlabs.org>
pppd/plugins/pppoe/common.c

index 8b0e636acb800ab923a6b6c6d2cb3053448189f2..9ddbcbd47f3202045c01141f9157f422840d77e8 100644 (file)
@@ -28,6 +28,7 @@ static char const RCSID[] =
 #include <errno.h>
 #include <stdlib.h>
 #include <syslog.h>    /* for LOG_DEBUG */
+#include <ctype.h>
 
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
@@ -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 {