From 8a244973b319be723a6e817dd123b558f528d6c9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pali=20Roh=C3=A1r?= Date: Fri, 1 Jan 2021 16:39:52 +0100 Subject: [PATCH] pppoe: Do not use %.*v and %.*B formats which are unsupported by C printf() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Pali Rohár --- pppd/plugins/pppoe/common.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pppd/plugins/pppoe/common.c b/pppd/plugins/pppoe/common.c index 9140ea9..f57d9de 100644 --- a/pppd/plugins/pppoe/common.c +++ b/pppd/plugins/pppoe/common.c @@ -203,7 +203,7 @@ void pppoe_printpkt(PPPoEPacket *packet, void (*printer)(void *, char *, ...), void *arg) { int len = ntohs(packet->length); - int i, tag, tlen, text; + int i, j, tag, tlen, text; switch (ntohs(packet->ethHdr.h_proto)) { case ETH_PPPOE_DISCOVERY: @@ -300,12 +300,13 @@ void pppoe_printpkt(PPPoEPacket *packet, } if (tlen) { if (text) - printer(arg, " %.*v", tlen, &packet->payload[i]); - else if (tlen <= 32) - printer(arg, " %.*B", tlen, &packet->payload[i]); - else - printer(arg, " %.32B... (length %d)", - &packet->payload[i], tlen); + printer(arg, " %.*s", tlen, &packet->payload[i]); + else { + for (j = 0; j < tlen && j < 32; j++) + printer(arg, " %02x", (unsigned) *(&packet->payload[i]+j)); + if (j < tlen) + printer(arg, "... (length %d)", tlen); + } } printer(arg, "]"); } -- 2.39.2