On 6/26/25 00:10, NIIBE Yutaka via Gcrypt-devel wrote:
* tests/t-common.h (read_textline): Increase the buffer size.

I understand that this is testsuite code, so a fixed stack buffer is not the serious problem it could otherwise be, but why not replace the fixed buffer with a heap-allocated buffer, expanded as needed using realloc()?  This would also allow the working buffer to be returned and freed by the caller, eliminating the final xstrdup() call.

A quick glance at src/stdmem.c suggests that libgcrypt already has the infrastructure to implement this.

I suggest making the buffer expansion power-of-2 starting from some initial size (256?) and doubling each time the buffer is filled without having read a complete line.  A hard limit (1MiB?) could be useful as well.


-- Jacob
_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel@gnupg.org
https://lists.gnupg.org/mailman/listinfo/gcrypt-devel

Reply via email to