]> granicus.if.org Git - strace/commitdiff
msghdr.c: limit IP_RECVOPTS/IP_RETOPTS output in abbrev mode
authorDmitry V. Levin <ldv@altlinux.org>
Sat, 2 Jul 2016 21:14:48 +0000 (21:14 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sat, 2 Jul 2016 21:14:48 +0000 (21:14 +0000)
* 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.

msghdr.c
tests/msg_control.c

index 0f9ba7145dd885aeec9de424ed7a6b56569c74e0..dd203260cbc252c7d9272c04683c2e2dbd4854cc 100644 (file)
--- 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("]");
index cecd5e8d28a2ca51bc4a103a48bed13d58c224a2..8d2888345ab95b19c334689d3c704defe6372dcc 100644 (file)
@@ -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