<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">On 6/26/25 00:10, NIIBE Yutaka via
Gcrypt-devel wrote:<span style="white-space: pre-wrap">
</span></div>
<blockquote type="cite"
cite="mid:b945002e44ce79227599e723fc1faa961494062b.1750914546.git.gniibe@fsij.org">
<pre wrap="" class="moz-quote-pre">* tests/t-common.h (read_textline): Increase the buffer size.
</pre>
</blockquote>
<p>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.<br>
</p>
<p>A quick glance at src/stdmem.c suggests that libgcrypt already
has the infrastructure to implement this.<br>
</p>
<p>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.<br>
</p>
<p><br>
</p>
<p>-- Jacob<br>
</p>
</body>
</html>