[PATCH v7 05/18] netlink: introduce nla_decoder_t to parse netlink attribute data

JingPiao Chen chenjingpiao at gmail.com
Wed Aug 16 15:24:10 UTC 2017


On Wed, Aug 16, 2017 at 08:49:31AM +0300, Dmitry V. Levin wrote:
> On Wed, Jun 28, 2017 at 09:40:00AM +0800, JingPiao Chen wrote:
> > * nlattr.h (nla_decoder_t): New typedef.
> > (DECL_NLA): New macro.
> > (decode_nlattr): Add decoders, size and opaque_data argument.
> > * nlattr.c: (decode_nlattr_with_data): Likewise.
> > (decode_nla_*): New functions.
> > * netlink_sock_diag.c (decode_inet_diag_req_compat)
> > (decode_inet_diag_req_v2, decode_inet_diag_msg)
> > (decode_netlink_diag_msg, (decode_packet_diag_msg)
> > (decode_smc_diag_msg, decode_unix_diag_msg): Add decoders,
> > size and opaque_data arguments. All callers updated.
> [...]
> > @@ -76,7 +80,13 @@ decode_nlattr_with_data(struct tcb *tcp,
> >  
> >  	if (nla_len > NLA_HDRLEN) {
> >  		tprints(", ");
> > -		printstrn(tcp, addr + NLA_HDRLEN, nla_len - NLA_HDRLEN);
> > +		if (!decoders
> > +		    || nla->nla_type >= size
> > +		    || !decoders[nla->nla_type]
> > +		    || !decoders[nla->nla_type](tcp, addr + NLA_HDRLEN,
> > +						nla_len - NLA_HDRLEN,
> > +						opaque_data))
> > +			printstrn(tcp, addr + NLA_HDRLEN, len - NLA_HDRLEN);
> 
> Why printstrn(tcp, addr + NLA_HDRLEN, nla_len - NLA_HDRLEN) was changed
> to  printstrn(tcp, addr + NLA_HDRLEN, len - NLA_HDRLEN) here?

Sorry, my mistake.

> 
> Fixed and added a test case for this bug.

--
JingPiao Chen




More information about the Strace-devel mailing list