Re: [PATCH 1/2] tests:common: Increse buffer size to allow input for PQC testing.

Werner Koch via Gcrypt-devel <[email protected]> Thu, 26 Jun 2025 09:36:45 +0200
Newsgroups gmane.comp.encryption.gpg.libgcrypt.devel
Message-ID <[email protected]>
On Thu, 26 Jun 2025 01:00, Jacob Bachmeyer said:

> 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

If we get such a long line something is wrong with the data.  After all
it should be easily editable by an editor.

In case someone wants to invest the time and regression risk; a switch
to es_read_line might be useful.  Something like

  maxlen = 16384; /* Set limit.  */
  while ((len = es_read_line (fp, &line, &length_of_line, &maxlen)) > 0)
    {
      if (!maxlen)
        {
          err = gpg_error (GPG_ERR_LINE_TOO_LONG);
          goto leave;
        }
      /* Strip newline and carriage return, if present.  */
      while (len > 0 && (line[len - 1] == '\n' || line[len - 1] == '\r'))
	line[--len] = '\0';

      if (split_fields (line, fields, DIM (fields)) < DIM(fields))
        continue; /* Skip empty lines and names w/o a value.  */
      if (*fields[0] == '#')
        continue; /* Skip comments.  */


libgpg-error (aka gpgrt) is anyway required.


Shalom-Salam,

   Werner


-- 
The pioneers of a warless world are the youth that
refuse military service.             - A. Einstein

_______________________________________________
Gcrypt-devel mailing list
[email protected]
https://lists.gnupg.org/mailman/listinfo/gcrypt-devel
openpgp-digital-signature.asc (application/pgp-signature, 247 B)
-----BEGIN PGP SIGNATURE-----

iIMEARYKACsWIQSHd0YfKgdOvEgNNZQZzByeCFsQegUCaFz4jQ0cd2tAZ251cGcu
b3JnAAoJEBnMHJ4IWxB6WhgA/AsCaLFspGsoeY4n+92hI6gFFSM+AG62YkD87mgp
nOBGAP4wWOgoVHTIm65YuWEacgEDAv3VJSs4zz/H0J9xOrFpAQ==
=1N5n
-----END PGP SIGNATURE-----