[LTP] [PATCH v2 04/33] keyctl12: Test KEYCTL_DESCRIBE with too small buffer
Cyril Hrubis
chrubis@suse.cz
Fri Sep 11 10:09:40 CEST 2026
Hi!
> +static void run(void)
> +{
> + size_t i;
> +
> + memset(buf, 0xAA, sizeof(buf));
> + TST_EXP_EQ_LI_SILENT(keyctl(KEYCTL_DESCRIBE, key, (unsigned long)buf,
> + desc_len - 1, 0), desc_len);
> + if (!TST_PASS)
> + return;
> +
> + for (i = 0; i < sizeof(buf); i++) {
> + if (buf[i] != (char)0xAA) {
> + tst_res(TFAIL,
> + "too small buffer was written to at offset %zu",
> + i);
> + return;
> + }
> + }
It may make sense to loop this with:
for (buf_len = 0; buf_len < desc_len; buf_len++) {
...
}
It should be fast and would increase the coverage..
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list