[LTP] [PATCH v3] read_all: Fix buffer too small for long paths
Cyril Hrubis
chrubis@suse.cz
Tue Sep 15 16:44:28 CEST 2026
Hi!
> Thanks for explaining the problem with the code. I took a better look at it.
> How about checking before the write instead:
>
> while (q->data[i]) {
> if (j >= BUFFER_SIZE - 1)
> tst_brk(TBROK, "Buffer is too small for path");
>
> q->popped[j++] = q->data[i];
> i = (i + 1) % QUEUE_SIZE;
> }
> q->popped[j] = '\0';
>
> j can never reach BUFFER_SIZE without TBROK, and PATH_MAX - 1 paths
> still fit. Does this look good to you?
Ah, righ, there is tst_brk(), sorry for missing that.
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list