From: Guy Harris Date: Wed, 8 Apr 2015 18:06:50 +0000 (-0700) Subject: Print strings with fn_printn(). X-Git-Tag: tcpdump-4.8.0~282^2~34 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/7a35ea87c1e5142eb25e30eaf9cefdc1507e0997 Print strings with fn_printn(). That filters out non-printable characters. --- diff --git a/print-rpki-rtr.c b/print-rpki-rtr.c index e2eaf94c..e009af54 100644 --- a/print-rpki-rtr.c +++ b/print-rpki-rtr.c @@ -289,9 +289,8 @@ rpki_rtr_pdu_print (netdissect_options *ndo, const u_char *tptr, u_int indent) } ND_TCHECK2(*tptr, text_length); if (text_length && (text_length <= tlen )) { - memcpy(buf, tptr, min(sizeof(buf)-1, text_length)); - buf[min(sizeof(buf) - 1, text_length)] = '\0'; - ND_PRINT((ndo, "%sError text: %s", indent_string(indent+2), buf)); + ND_PRINT((ndo, "%sError text: ", indent_string(indent+2))); + fn_printn(ndo, buf, text_length, ndo->ndo_snapend); } } break; diff --git a/tests/kday5.out b/tests/kday5.out index 446ffa30..50c48b2e 100644 --- a/tests/kday5.out +++ b/tests/kday5.out @@ -30,14 +30,6 @@ IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, 0x0030: afc4 39a4 0db9 7aa5 6873 33e8 RPKI-RTRv65, Error Report PDU (10), length: 66 Error code: Unknown (66), Encapsulated PDU length: 80 - Error text: ¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹Ã¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹ - - - - - - - - + Error text: [|RPKI-RTR] EXIT CODE 00000100