From: Dmitry V. Levin Date: Sat, 2 Jul 2016 21:14:48 +0000 (+0000) Subject: msghdr.c: limit IP_RECVOPTS/IP_RETOPTS output in abbrev mode X-Git-Tag: v4.13~74 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=67135824fe8f1a78349e5297bf0db323925376ec;p=strace msghdr.c: limit IP_RECVOPTS/IP_RETOPTS output in abbrev mode * msghdr.c (print_cmsg_ip_opts): Do not print more than max_strlen bytes of ip options in abbrev mode. * tests/msg_control.c (print_ip_opts): Use DEFAULT_STRLEN. (test_sol_ip): Test IP_RETOPTS output in abbrev mode. --- diff --git a/msghdr.c b/msghdr.c index 0f9ba714..dd203260 100644 --- a/msghdr.c +++ b/msghdr.c @@ -134,6 +134,10 @@ print_cmsg_ip_opts(struct tcb *tcp, const void *cmsg_data, for (i = 0; i < data_len; ++i) { if (i) tprints(", "); + if (abbrev(tcp) && i >= max_strlen) { + tprints("..."); + break; + } tprintf("0x%02x", opts[i]); } tprints("]"); diff --git a/tests/msg_control.c b/tests/msg_control.c index cecd5e8d..8d288834 100644 --- a/tests/msg_control.c +++ b/tests/msg_control.c @@ -478,6 +478,12 @@ print_ip_opts(const void *const cmsg_data, const unsigned int data_len) for (i = 0; i < data_len; ++i) { if (i) printf(", "); +#ifndef VERBOSE_MSGHDR + if (i >= DEFAULT_STRLEN) { + printf("..."); + break; + } +#endif printf("0x%02x", opts[i]); } } @@ -608,6 +614,9 @@ test_sol_ip(struct msghdr *const mh, void *const page) test_ip_opts(mh, page, VAL_STR(IP_RETOPTS), 6); test_ip_opts(mh, page, VAL_STR(IP_RETOPTS), 7); test_ip_opts(mh, page, VAL_STR(IP_RETOPTS), 8); + test_ip_opts(mh, page, VAL_STR(IP_RETOPTS), DEFAULT_STRLEN - 1); + test_ip_opts(mh, page, VAL_STR(IP_RETOPTS), DEFAULT_STRLEN); + test_ip_opts(mh, page, VAL_STR(IP_RETOPTS), DEFAULT_STRLEN + 1); #ifdef IP_CHECKSUM test_ip_recverr(mh, page, VAL_STR(IP_RECVERR)); #endif