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>
#include <errno.h>
#include <stdlib.h>
#include <syslog.h> /* for LOG_DEBUG */
+#include <ctype.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
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 {