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

Dmitry V. Levin ldv at altlinux.org
Wed Aug 16 05:49:31 UTC 2017


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?

Fixed and added a test case for this bug.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20170816/8d244cd8/attachment.bin>


More information about the Strace-devel mailing list