[PATCH 04/27] tests: check decoding of NETLINK_CRYPTO messages
Dmitry V. Levin
ldv at altlinux.org
Sat Jul 22 18:55:28 UTC 2017
On Sat, Jul 22, 2017 at 08:43:34PM +0800, JingPiao Chen wrote:
> * tests/netlink_crypto.c: Include "test_netlink.h"
> instead of "netlink.h".
> (test_crypto_msg_newalg, test_crypto_msg_delrng): New functions.
> (main): Use them.
> ---
> tests/netlink_crypto.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 44 insertions(+), 1 deletion(-)
>
> diff --git a/tests/netlink_crypto.c b/tests/netlink_crypto.c
> index 376baa8..a0586dd 100644
> --- a/tests/netlink_crypto.c
> +++ b/tests/netlink_crypto.c
> @@ -34,7 +34,7 @@
> # include <unistd.h>
> # include <sys/socket.h>
> # include <linux/cryptouser.h>
> -# include "netlink.h"
> +# include "test_netlink.h"
>
> static void
> test_nlmsg_type(const int fd)
> @@ -87,6 +87,45 @@ test_nlmsg_flags(const int fd)
> (unsigned) sizeof(nlh), sprintrc(rc));
> }
>
> +static void
> +test_crypto_msg_newalg(const int fd)
> +{
> + void *const nlh0 = tail_alloc(NLMSG_HDRLEN);
> +
> + static const struct crypto_user_alg alg = {
> + .cru_name = "abcd",
> + .cru_driver_name = "efgh",
> + .cru_module_name = "ijkl",
> + .cru_type = 0xabcdfabc,
> + .cru_mask = 0xfedabacd,
> + .cru_refcnt = 0xbcacfacd,
> + .cru_flags = 0xefacdbad
> + };
> + TEST_NETLINK_OBJECT_EX(fd, nlh0,
> + CRYPTO_MSG_NEWALG, NLM_F_REQUEST,
> + alg, print_quoted_memory,
> + printf("{cru_name=\"abcd\""
> + ", cru_driver_name=\"efgh\""
> + ", cru_module_name=\"ijkl\"");
> + PRINT_FIELD_X(", ", alg, cru_type);
> + PRINT_FIELD_X(", ", alg, cru_mask);
> + PRINT_FIELD_U(", ", alg, cru_refcnt);
> + PRINT_FIELD_X(", ", alg, cru_flags);
> + printf("}"));
> +}
I think we should also check that non-null-terminated string fields
of crypto structures are decoded properly.
--
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20170722/6e9331cc/attachment.bin>
More information about the Strace-devel
mailing list