nlattr: add size check to decode_nla_xval and decode_nla_flags
authorEugene Syromyatnikov <evgsyr@gmail.com>
Wed, 23 May 2018 16:50:48 +0000 (18:50 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 6 Jun 2018 15:10:37 +0000 (15:10 +0000)
commitc0827b1ae93fa892a3e9cd97940d2b846b97b1b5
tree53b590449f394c10a2a17dc5a49273ba2f8ab122
parent6d98338f09c7f25cf2575db6c1cfd51fd5cdfc6f
nlattr: add size check to decode_nla_xval and decode_nla_flags

If the field size is known, do not print as valid numbers those
attributes that are too short, and ignore extra data.

This change puts xval/flags printing in line with the reset of attribute
decoders.

* nlattr.h (struct decode_nla_xlat_opts): Add size field.
* nlattr.c (decode_nla_xval, decode_nla_flags): Check that len is at
least opts->size, limit len to opts->size.
(decode_nla_ip_proto): Specify size of 1.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
nlattr.c
nlattr.h