Network order or Host order for raw xlat style

shankarapailoor shankarapailoor at gmail.com
Mon Jan 7 01:18:22 UTC 2019


Attached is an updated patch.

> I bet it is not v1. :)

Haha that's fair. In the future should I keep squashing the commits
but just increment the re-roll count? I've made it v3.

>printxval_searchn_ex seems to be more appropriate replacement than
printxvals_ex.

Ack. Fixed in this patch.

>The fix is to call sprintrc() right after the syscall and save the result
into a variable that could be passed later to printf().

Done. Thanks!

On Sun, Jan 6, 2019 at 4:59 PM Dmitry V. Levin <ldv at altlinux.org> wrote:
>
> On Sun, Jan 06, 2019 at 04:43:42PM -0800, shankarapailoor wrote:
> > Thanks Dmitry! Here is an updated patch.
> [...]
> > Subject: [PATCH v1] handle xlat styles when decoding sockaddr_in and
> >  sockaddr_in6
>
> I bet it is not v1. :)
>
> [...]
> > @@ -374,15 +413,43 @@ print_sockaddr_data_nl(const void *const buf, const int addrlen)
> >       PRINT_FIELD_0X(", ", *sa_nl, nl_groups);
> >  }
> >
> > +static void
> > +print_sll_protocol(const struct sockaddr_ll *const sa_ll)
> > +{
> > +     int x_style = xlat_verbose(xlat_verbosity);
> > +
> > +     tprints("sll_protocol=");
> > +     if (x_style != XLAT_STYLE_ABBREV)
> > +             print_quoted_string((const char *) &sa_ll->sll_protocol,
> > +                                     sizeof(sa_ll->sll_protocol),
> > +                                     QUOTE_FORCE_HEX);
> > +
> > +     if (x_style == XLAT_STYLE_RAW)
> > +             return;
> > +
> > +     if (x_style == XLAT_STYLE_VERBOSE)
> > +             tprints(" /* ");
> > +
> > +     tprints("htons(");
> > +     printxvals_ex(ntohs(sa_ll->sll_protocol),
> > +                     "ETH_P_???",
> > +                     XLAT_STYLE_ABBREV,
> > +                     ethernet_protocols,
> > +                     NULL);
>
> As the original function used before this change was
>         printxval_search(ethernet_protocols, ntohs(sa_ll->sll_protocol),
>                          "ETH_P_???");
> printxval_searchn_ex seems to be more appropriate replacement than
> printxvals_ex.
>
> [...]
> > +     int rc = connect(-1, ll, len);
> > +#if XLAT_RAW
> > +     printf("connect(-1, {sa_family=%#x"
> > +            ", sll_protocol=", AF_PACKET);
> > +     print_quoted_hex(&c_ll.sll_protocol, sizeof(c_ll.sll_protocol));
> > +     printf(", sll_ifindex=%u, sll_hatype=%#x"
> > +            ", sll_pkttype=%u, sll_halen=%u, sll_addr="
> > +            "[%#02x, %#02x, %#02x, %#02x, %#02x, %#02x, %#02x, %#02x]"
> > +            "}, %u) = %s\n",
> > +            c_ll.sll_ifindex, ARPHRD_ETHER,
> > +            PACKET_HOST, c_ll.sll_halen,
> > +            c_ll.sll_addr[0], c_ll.sll_addr[1],
> > +            c_ll.sll_addr[2], c_ll.sll_addr[3],
> > +            c_ll.sll_addr[4], c_ll.sll_addr[5],
> > +            c_ll.sll_addr[6], c_ll.sll_addr[7],
> > +            len, sprintrc(rc));
>
> This variant has essentially the same errno clobbering issue
> as the previous one because sprintrc() uses errno.
>
> The fix is to call sprintrc() right after the syscall and save the result
> into a variable that could be passed later to printf().
>
>
> --
> ldv
> --
> Strace-devel mailing list
> Strace-devel at lists.strace.io
> https://lists.strace.io/mailman/listinfo/strace-devel



-- 
Regards,
Shankara Pailoor
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v3-0001-handle-xlat-styles-when-decoding-sockaddr_in-and-.patch
Type: text/x-patch
Size: 15991 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20190106/9c93ef1d/attachment.bin>


More information about the Strace-devel mailing list