]> granicus.if.org Git - strace/commitdiff
tests/test_nlattr.h: avoid testing cropped objects of size 1
authorEugene Syromyatnikov <evgsyr@gmail.com>
Wed, 23 May 2018 16:45:43 +0000 (18:45 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 25 May 2018 09:15:03 +0000 (09:15 +0000)
* tests/test_nlattr.h (TEST_NLATTR_OBJECT_EX_): Check
"len < sizeof(obj_)" case only if "sizeof(obj_) > 1".

tests/test_nlattr.h

index be092c3b4c4503a19fd033a750d5182ea318762d..fe681ae3d4d0ab65500858d205be3f3020ab2237 100644 (file)
@@ -106,11 +106,12 @@ print_nlattr(const unsigned int nla_len, const char *const nla_type)
                        sizeof(obj_) - 1 > DEFAULT_STRLEN               \
                        ? DEFAULT_STRLEN : (int) sizeof(obj_) - 1;      \
                /* len < sizeof(obj_) */                                \
-               TEST_NLATTR_((fd_), (nlh0_), (hdrlen_),                 \
-                       (init_msg_), (print_msg_),                      \
-                       (nla_type_), (nla_type_str_),                   \
-                       plen, (pattern_), plen,                         \
-                       (fallback_func)((pattern_), plen));             \
+               if (plen > 0)                                           \
+                       TEST_NLATTR_((fd_), (nlh0_), (hdrlen_),         \
+                               (init_msg_), (print_msg_),              \
+                               (nla_type_), (nla_type_str_),           \
+                               plen, (pattern_), plen,                 \
+                               (fallback_func)((pattern_), plen));     \
                /* short read of sizeof(obj_) */                        \
                TEST_NLATTR_((fd_), (nlh0_), (hdrlen_),                 \
                        (init_msg_), (print_msg_),                      \
@@ -212,15 +213,16 @@ print_nlattr(const unsigned int nla_len, const char *const nla_type)
                        sizeof(obj_) - 1 > DEFAULT_STRLEN               \
                        ? DEFAULT_STRLEN : (int) sizeof(obj_) - 1;      \
                /* len < sizeof(obj_) */                                \
-               TEST_NLATTR_((fd_), (nlh0_) - NLA_HDRLEN * depth_,      \
-                       (hdrlen_) + NLA_HDRLEN * depth_,                \
-                       (init_msg_), (print_msg_),                      \
-                       (nla_type_), (nla_type_str_),                   \
-                       plen, (pattern_), plen,                         \
-                       print_quoted_hex((pattern_), plen);             \
-                       size_t i;                                       \
-                       for (i = 0; i < depth_; ++i)                    \
-                               printf("}"));                           \
+               if (plen > 0)                                           \
+                       TEST_NLATTR_((fd_), (nlh0_) - NLA_HDRLEN * depth_, \
+                               (hdrlen_) + NLA_HDRLEN * depth_,        \
+                               (init_msg_), (print_msg_),              \
+                               (nla_type_), (nla_type_str_),           \
+                               plen, (pattern_), plen,                 \
+                               print_quoted_hex((pattern_), plen);     \
+                               size_t i;                               \
+                               for (i = 0; i < depth_; ++i)            \
+                                       printf("}"));                   \
                /* short read of sizeof(obj_) */                        \
                TEST_NLATTR_((fd_), (nlh0_) - NLA_HDRLEN * depth_,      \
                        (hdrlen_) + NLA_HDRLEN * depth_,                \