ObjFW  Check-in [da02ae46f0]

Overview
Comment:OFOpenSSLTLSStream: Fix stuck reads
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: da02ae46f02cb5661d4cb1bc072940c7330ec64807d3157a723e22c817991a01
User & Date: js on 2022-03-10 19:37:44
Other Links: manifest | tags
Context
2022-03-10
19:53
GitHub Actions: Run apt-get update before install check-in: 9fd333e53b user: js tags: trunk
19:37
OFOpenSSLTLSStream: Fix stuck reads check-in: da02ae46f0 user: js tags: trunk
2022-03-03
21:21
README.md: Add a "Donations" section check-in: 6b8e13fbde user: js tags: trunk
Changes

Modified src/tls/OFOpenSSLTLSStream.m from [01687732e1] to [2ce21e69b2].

120
121
122
123
124
125
126
127












128
129
130
131
132
133
134
120
121
122
123
124
125
126

127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145







-
+
+
+
+
+
+
+
+
+
+
+
+







			    (int)tmp);
		} @catch (OFReadFailedException *e) {
			if (e.errNo != EWOULDBLOCK && e.errNo != EAGAIN)
				@throw e;
		}
	}

	if ((ret = SSL_read_ex(_SSL, buffer, length, &bytesRead)) != 1) {
	ret = SSL_read_ex(_SSL, buffer, length, &bytesRead);

	if (BIO_ctrl_pending(_writeBIO) > 0) {
		int tmp = BIO_read(_writeBIO, _buffer, bufferSize);

		OFEnsure(tmp >= 0);

		[_underlyingStream writeBuffer: _buffer length: tmp];
		[_underlyingStream flushWriteBuffer];
	}

	if (ret != 1) {
		/*
		 * The underlying stream might have had data ready, but not
		 * enough for OpenSSL to return decrypted data. This means the
		 * caller might have observed the TLS stream for reading, got a
		 * ready signal and read - and expects the read to succeed, not
		 * to fail with EWOULDBLOCK, as it was signaled ready.
		 * Therefore, return 0, as we could read 0 decrypted bytes, but