]> granicus.if.org Git - strace/commitdiff
tests/test_nlattr.h: fix pointer calculation in TEST_NLATTR_ARRAY, take 2
authorEugene Syromyatnikov <evgsyr@gmail.com>
Thu, 10 May 2018 17:33:52 +0000 (19:33 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 30 May 2018 10:54:34 +0000 (10:54 +0000)
The old code works only when an array contains exactly two items.

* tests/test_nlattr.h (TEST_NLATTR_ARRAY): Fix pointer address
for the case of incomplete read.

tests/test_nlattr.h

index 84f99ba082d7e409f69b7cd0a0a30f5a329edc71..84125e009cd6a9194d0d3bafe9f214b14aa0a942 100644 (file)
@@ -310,7 +310,7 @@ print_nlattr(const unsigned int nla_len, const char *const nla_type)
                        }                                               \
                        printf(", ... /* %p */]}",                      \
                               RTA_DATA(TEST_NLATTR_nla)                \
-                               + sizeof((obj_)[0])));                  \
+                               + sizeof(obj_) - sizeof((obj_)[0])));   \
                /* sizeof(obj_) */                                      \
                TEST_NLATTR_((fd_), (nlh0_) - NLA_HDRLEN,               \
                        (hdrlen_) + NLA_HDRLEN,                         \