diff options
author | Dmitry V. Levin <ldv@altlinux.org> | 2017-09-01 08:41:08 +0000 |
---|---|---|
committer | Dmitry V. Levin <ldv@altlinux.org> | 2017-09-01 08:41:08 +0000 |
commit | 90695173828c729a80b332b584bd288a1acb30bf (patch) | |
tree | ab7de5c98c2f7de72d9c582bcaf1433c2e3941d5 | |
parent | b738f44a524772498bb08093eb109d38b6510355 (diff) | |
download | strace-90695173828c729a80b332b584bd288a1acb30bf.tar.gz |
rtnl_link: enhance decoding of struct rtnl_link_stats{,64}
Enhance runtime detection of struct rtnl_link_stats.rx_nohandler
and struct rtnl_link_stats64.rx_nohandler.
* rtnl_link.c (decode_rtnl_link_stats): Do not accept structure length
greater than min_size but less than sizeof(struct rtnl_link_stats).
(decode_rtnl_link_stats64): Likewise, so not accept structure length
greater than min_size but less than sizeof(struct rtnl_link_stats64).
-rw-r--r-- | rtnl_link.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/rtnl_link.c b/rtnl_link.c index 990968424..73b94aef8 100644 --- a/rtnl_link.c +++ b/rtnl_link.c @@ -50,11 +50,15 @@ decode_rtnl_link_stats(struct tcb *const tcp, struct rtnl_link_stats st; const unsigned int min_size = offsetofend(struct rtnl_link_stats, tx_compressed); - const unsigned int size = len < sizeof(st) ? min_size : sizeof(st); + const unsigned int def_size = sizeof(st); + const unsigned int size = + (len >= def_size) ? def_size : + ((len == min_size) ? min_size : 0); - if (len < min_size) + if (!size) return false; - else if (!umoven_or_printaddr(tcp, addr, size, &st)) { + + if (!umoven_or_printaddr(tcp, addr, size, &st)) { PRINT_FIELD_U("{", st, rx_packets); PRINT_FIELD_U(", ", st, tx_packets); PRINT_FIELD_U(", ", st, rx_bytes); @@ -82,7 +86,7 @@ decode_rtnl_link_stats(struct tcb *const tcp, PRINT_FIELD_U(", ", st, rx_compressed); PRINT_FIELD_U(", ", st, tx_compressed); #ifdef HAVE_STRUCT_RTNL_LINK_STATS_RX_NOHANDLER - if (len >= sizeof(st)) + if (len >= def_size) PRINT_FIELD_U(", ", st, rx_nohandler); #endif tprints("}"); @@ -196,11 +200,15 @@ decode_rtnl_link_stats64(struct tcb *const tcp, struct rtnl_link_stats64 st; const unsigned int min_size = offsetofend(struct rtnl_link_stats64, tx_compressed); - const unsigned int size = len < sizeof(st) ? min_size : sizeof(st); + const unsigned int def_size = sizeof(st); + const unsigned int size = + (len >= def_size) ? def_size : + ((len == min_size) ? min_size : 0); - if (len < min_size) + if (!size) return false; - else if (!umoven_or_printaddr(tcp, addr, size, &st)) { + + if (!umoven_or_printaddr(tcp, addr, size, &st)) { PRINT_FIELD_U("{", st, rx_packets); PRINT_FIELD_U(", ", st, tx_packets); PRINT_FIELD_U(", ", st, rx_bytes); @@ -228,7 +236,7 @@ decode_rtnl_link_stats64(struct tcb *const tcp, PRINT_FIELD_U(", ", st, rx_compressed); PRINT_FIELD_U(", ", st, tx_compressed); #ifdef HAVE_STRUCT_RTNL_LINK_STATS64_RX_NOHANDLER - if (len >= sizeof(st)) + if (len >= def_size) PRINT_FIELD_U(", ", st, rx_nohandler); #endif tprints("}"); |