TEST_NLATTR_OBJECT_EX(fd, nlh0, hdrlen,
init_crypto_user_alg, print_crypto_user_alg,
CRYPTOCFGA_REPORT_HASH,
- pattern, rhash, print_quoted_memory,
+ pattern, rhash, sizeof(rhash),
+ print_quoted_memory,
printf("{type=\"efgh\"");
PRINT_FIELD_U(", ", rhash, blocksize);
PRINT_FIELD_U(", ", rhash, digestsize);
TEST_NLATTR_OBJECT_EX(fd, nlh0, hdrlen,
init_crypto_user_alg, print_crypto_user_alg,
CRYPTOCFGA_REPORT_BLKCIPHER,
- pattern, rblkcipher, print_quoted_memory,
+ pattern, rblkcipher, sizeof(rblkcipher),
+ print_quoted_memory,
printf("{type=\"abcd\", geniv=\"efgh\"");
PRINT_FIELD_U(", ", rblkcipher, blocksize);
PRINT_FIELD_U(", ", rblkcipher, min_keysize);
TEST_NLATTR_OBJECT_EX(fd, nlh0, hdrlen,
init_crypto_user_alg, print_crypto_user_alg,
CRYPTOCFGA_REPORT_AEAD,
- pattern, raead, print_quoted_memory,
+ pattern, raead, sizeof(raead),
+ print_quoted_memory,
printf("{type=\"abcd\", geniv=\"efgh\"");
PRINT_FIELD_U(", ", raead, blocksize);
PRINT_FIELD_U(", ", raead, maxauthsize);
TEST_NLATTR_OBJECT_EX(fd, nlh0, hdrlen,
init_crypto_user_alg, print_crypto_user_alg,
CRYPTOCFGA_REPORT_RNG,
- pattern, rrng, print_quoted_memory,
+ pattern, rrng, sizeof(rrng), print_quoted_memory,
printf("{type=\"abcd\"");
PRINT_FIELD_U(", ", rrng, seedsize);
printf("}"));
TEST_NLATTR_OBJECT_EX(fd, nlh0, hdrlen,
init_crypto_user_alg, print_crypto_user_alg,
CRYPTOCFGA_REPORT_CIPHER,
- pattern, rcipher, print_quoted_memory,
+ pattern, rcipher, sizeof(rcipher),
+ print_quoted_memory,
printf("{type=\"abcd\"");
PRINT_FIELD_U(", ", rcipher, blocksize);
PRINT_FIELD_U(", ", rcipher, min_keysize);
#define TEST_NLATTR_OBJECT_EX_(fd_, nlh0_, hdrlen_, \
init_msg_, print_msg_, \
nla_type_, nla_type_str_, \
- pattern_, obj_, fallback_func, ...) \
+ pattern_, obj_, minsz_, fallback_func, ...) \
do { \
- const unsigned int plen = \
- sizeof(obj_) - 1 > DEFAULT_STRLEN \
- ? DEFAULT_STRLEN : (int) sizeof(obj_) - 1; \
+ const unsigned int plen = MIN((minsz_) - 1, DEFAULT_STRLEN); \
/* len < sizeof(obj_) */ \
if (plen > 0) \
TEST_NLATTR_((fd_), (nlh0_), (hdrlen_), \
(init_msg_), (print_msg_), \
(nla_type_), (nla_type_str_), \
sizeof(obj_), \
- (pattern_), sizeof(obj_) - 1, \
+ (pattern_), (minsz_) - 1, \
printf("%p", \
RTA_DATA(NLMSG_ATTR(nlh, (hdrlen_))))); \
/* sizeof(obj_) */ \
#define TEST_NLATTR_OBJECT_EX(fd_, nlh0_, hdrlen_, \
init_msg_, print_msg_, \
nla_type_, \
- pattern_, obj_, fallback_func, ...) \
+ pattern_, obj_, minsz_, fallback_func, ...) \
TEST_NLATTR_OBJECT_EX_((fd_), (nlh0_), (hdrlen_), \
(init_msg_), (print_msg_), \
(nla_type_), #nla_type_, \
- (pattern_), (obj_), (fallback_func), \
- __VA_ARGS__)
+ (pattern_), (obj_), (minsz_), \
+ (fallback_func), __VA_ARGS__)
#define TEST_NLATTR_OBJECT(fd_, nlh0_, hdrlen_, \
init_msg_, print_msg_, \
TEST_NLATTR_OBJECT_EX_((fd_), (nlh0_), (hdrlen_), \
(init_msg_), (print_msg_), \
(nla_type_), #nla_type_, \
- (pattern_), (obj_), print_quoted_hex, \
- __VA_ARGS__)
+ (pattern_), (obj_), sizeof(obj_), \
+ print_quoted_hex, __VA_ARGS__)
+
+#define TEST_NLATTR_OBJECT_MINSZ(fd_, nlh0_, hdrlen_, \
+ init_msg_, print_msg_, \
+ nla_type_, pattern_, obj_, minsz_, ...) \
+ TEST_NLATTR_OBJECT_EX_((fd_), (nlh0_), (hdrlen_), \
+ (init_msg_), (print_msg_), \
+ (nla_type_), #nla_type_, \
+ (pattern_), (obj_), (minsz_), \
+ print_quoted_hex, __VA_ARGS__)
#define TEST_NLATTR_ARRAY(fd_, nlh0_, hdrlen_, \
init_msg_, print_msg_, \