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

Attachment: openpgp-digital-signature.asc
Description: PGP signature

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

Reply via email to