Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1irT5N-0005xm-VL for pgsql-hackers@arkaria.postgresql.org; Tue, 14 Jan 2020 20:46:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1irT4O-0008H7-JD for pgsql-hackers@arkaria.postgresql.org; Tue, 14 Jan 2020 20:45:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1irT4O-0008F9-AG for pgsql-hackers@lists.postgresql.org; Tue, 14 Jan 2020 20:45:48 +0000 Received: from tamriel.snowman.net ([2001:470:e38f::11]) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1irT3t-0000RZ-VR for pgsql-hackers@lists.postgresql.org; Tue, 14 Jan 2020 20:45:47 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 0DCB85F799; Tue, 14 Jan 2020 15:45:18 -0500 (EST) Date: Tue, 14 Jan 2020 15:45:17 -0500 From: Stephen Frost To: Tom Lane Cc: Peter , pgsql-hackers@lists.postgresql.org Subject: Re: 12.1 not useable: clientlib fails after a dozen queries (GSSAPI ?) Message-ID: <20200114204517.GD3195@tamriel.snowman.net> References: <7042.1578595681@sss.pgh.pa.us> <20200109205319.GA85142@gate.oper.dinoex.org> <15232.1578605504@sss.pgh.pa.us> <20200110022342.GA92515@gate.oper.dinoex.org> <12348.1578679149@sss.pgh.pa.us> <20200110210337.GA9580@gate.oper.dinoex.org> <26433.1578714710@sss.pgh.pa.us> <31477.1578756495@sss.pgh.pa.us> <20200114201207.GA3195@tamriel.snowman.net> <28741.1579033320@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="5i06EVIDeN5/qxBX" Content-Disposition: inline In-Reply-To: <28741.1579033320@sss.pgh.pa.us> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --5i06EVIDeN5/qxBX Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Tom Lane (tgl@sss.pgh.pa.us) wrote: > Stephen Frost writes: > > * Tom Lane (tgl@sss.pgh.pa.us) wrote: > >> ... We must remember how much data we encrypted > >> and then discount that much of the caller's supplied data next time. > >> There are hints in the existing comments that somebody understood > >> this at one point, but the code isn't acting that way today. >=20 > > That's a case I hadn't considered and you're right- the algorithm > > certainly wouldn't work in such a case. I don't recall specifically if > > the code had handled it better previously, or not, but I do recall there > > was something previously about being given a buffer and then having the > > API defined as "give me back the exact same buffer because I had to > > stop" and I recall finding that to ugly, but I get it now, seeing this > > issue. I'd certainly be happier if there was a better alternative but I > > don't know that there really is. >=20 > Yeah. The only bright spot is that there's no reason for the caller > to change its mind about what it wants to write, so that this restriction > doesn't really affect anything. (The next call might potentially add > *more* data at the end, but that's fine.) Right, makes sense. > I realized when I got into it that my sketch above also considered only > part of the problem. In the general case, we might've encrypted some data > from the current write request and successfully sent it, and then > encrypted some more data but been unable to (fully) send that packet. > In this situation, it's best to report that we wrote however much data > corresponds to the fully sent packet(s). That way the caller can discard > that data from its buffer. We can't report the data corresponding to the > in-progress packet as being written, though, or we have the > might-not-get-another-call problem. Fortunately the API already has the > notion of a partial write, since the underlying socket calls do. Yeah, I see how that's also an issue and agree that it makes sense to report back what's been written and sent as a partial write, and not report back everything we've "consumed" since we might not get called again in that case. Thanks! Stephen --5i06EVIDeN5/qxBX Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJeHihdAAoJEO1sijiDR2RV9LwQAImNF3eT3wrDatwxZoj90gSR eMTpAvdOTJJNxMfiE7UB9za2H9TULms5U6YHlpDOpIugr5eoNoGkb8eSQoHim3Nu dtYRZ2B+avoURHsgCjdFecpqTAI+njW2okRZ9qOHunYM9inYDYFa8dUlFSPHeT30 AmjQ3xayU9iIhNY9TB1KVJSkf0GMD6MmiiHwENdxX3zCaa+ex1+757F57gOIVs5Q WVa/2lDuo/ixycRF40+ZW3U304vq3vSPhjtyDK39r5mXOMLZ1TY3YM/DAh06LYAu rAgbbA6Xk4Niivq682I4NvthmY2bgYgMlm5HSE/S8k51Y+3iVaRn3/hPhei7jDXE bgtW+WqzPIH5dxJtXavGq6UWcXGPp3wXirP7/K+8SZIri6NOTpkOfHSHuZlm51b9 Wy50ufBsYu2z+RhFkgrd7jTVunjJONSacNrLlHW3geJsKh1PxMoZ8TICaxW6Xs0F derVeRgwnI+b+GSMvHfAHoo3Z6fZutzlc8hLwqakjcnOdkEzt5Cejwbf9tUr6C+Q lRmctzZN9VcDxaJ1K4K2y+zF4Dl+5KQ6WBIc/7KPD5u1igel6FQx4vRgqvqSZsRc R/xuZkegohZZZZ1rIZ5O+YRGhiSKltEWZAFuoeRHU6eYzbN4QDMrloeMqQ7cklwg DbgIAtNUJrcXI/qxiBgs =+Cm8 -----END PGP SIGNATURE----- --5i06EVIDeN5/qxBX--