Re: STDIN behaviour change ( 2.2.44/2.4.5)

Werner Koch via Gnupg-devel <[email protected]>
Newsgroups gmane.comp.encryption.gpg.devel
Message-ID <[email protected]>
Hi!

On Wed, 11 Dec 2024 19:58, Dirk-Willem van Gulik said:

> After an update to 2.4.5 - we’re seeing an odd behaviour change (not sure it is regression) - where GPG seems to wait for an EOF as opposed to the end of message.

I am not sure what you mean by EOF vs. end of message.  How should gpg
distinguish your two use cases - it reads the input and acts upon it.
There might have been changes in the input buffering but that can't
be the problem.

On Unix we use read(2) until it returns 0 to indicate EOF or until we
see an error and the errno is EPIPE.  All other errors will print an
error message.

For reference  the code in 2.2 is:

	  do
	    {
	      n = read (f, buf, size);
	    }
	  while (n == -1 && errno == EINTR);
	  if (n == -1)
	    {			/* error */
	      if (errno != EPIPE)
		{
		  rc = gpg_error_from_syserror ();
		  log_error ("%s: read error: %s\n",
			     a->fname, strerror (errno));
		}
	    }
	  else if (!n)
	    {			/* eof */
	      a->eof_seen = 1;
	      rc = -1;
	    }
	  else
	    {
	      nbytes = n;
	    }

and in 2.4:

        read_more:
          do
            {
              n = read (f, buf + nbytes, size - nbytes);
            }
          while (n == -1 && errno == EINTR);
          if (n > 0)
            {
              nbytes += n;
              if (nbytes < size)
                goto read_more;
            }
          else if (!n) /* eof */
            {
              if (nbytes)
                a->delayed_rc = -1;
              else
                {
                  a->eof_seen = 1;
                  rc = -1;
                }
            }
          else /* error */
            {
              rc = gpg_error_from_syserror ();
              if (gpg_err_code (rc) != GPG_ERR_EPIPE)
                log_error ("%s: read error: %s\n", a->fname, gpg_strerror (rc));
              if (nbytes)
                {
                  a->delayed_rc = rc;
                  rc = 0;
                }
            }

The change in 2.4 (from 2018) is due to
https://dev.gnupg.org/rGbfc11816444512b4ebcc6617d3c3b5988e753de3
which tries to utilize larger buffers.


Shalom-Salam,

   Werner


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

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

iIMEARYIACsWIQSHd0YfKgdOvEgNNZQZzByeCFsQegUCZ1rEOg0cd2tAZ251cGcu
b3JnAAoJEBnMHJ4IWxB6IScA/0TSRtXJ9n+6cSuZSRcmtHLWfD6TtWWyhqs1YmT9
/zn9AQDSsgVw6V4hyPfCFohiZJc01ONn086fCZTqaL4Eh0JoCg==
=1vf9
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.