[LTP] [PATCH v2 08/33] keyctl16: Test KEYCTL_GET_SECURITY truncated copy
Cyril Hrubis
chrubis@suse.cz
Fri Sep 11 10:30:05 CEST 2026
Hi!
> +static void run(void)
> +{
> + size_t i;
> +
> + memset(buf, 0xAA, sizeof(buf));
> + TST_EXP_EQ_LI_SILENT(keyctl(KEYCTL_GET_SECURITY, key,
> + (unsigned long)buf, 1, 0), sec_len);
> + if (!TST_PASS)
> + return;
> +
> + if (buf[0] == (char)0xAA) {
> + tst_res(TFAIL, "nothing was copied into the buffer");
> + return;
> + }
> +
> + for (i = 1; i < sizeof(buf); i++) {
> + if (buf[i] != (char)0xAA) {
> + tst_res(TFAIL, "copy overran the buffer at offset %zu",
> + i);
> + return;
> + }
> + }
> +
> + tst_res(TPASS, "exactly one byte copied, full length %ld returned",
> + sec_len);
Here as well, we can loop over all truncated lengths.
> +}
> +
> +static struct tst_test test = {
> + .setup = setup,
> + .test_all = run,
> +};
>
> --
> 2.51.0
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list