ObjFW  Check-in [6bea538b73]

Overview
Comment:Fix OFOpenSSLTLSStreams hanging in some cases
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 6bea538b73d2fc153392e09daeb226209173d862f3fb6af92e16ee7a314af342
User & Date: js on 2023-09-07 12:31:22
Other Links: manifest | tags
Context
2023-09-07
23:58
Update buildsys check-in: f17d5b529e user: js tags: trunk
12:31
Fix OFOpenSSLTLSStreams hanging in some cases check-in: 6bea538b73 user: js tags: trunk
2023-09-06
19:01
Fix headers for ObjC++ check-in: c98df52cff user: js tags: trunk
Changes

Modified src/tls/OFOpenSSLTLSStream.m from [d93e2e9a8c] to [4f42a57c0b].

15
16
17
18
19
20
21

22
23
24
25
26
27
28

#include "config.h"

#include <errno.h>

#import "OFOpenSSLTLSStream.h"
#import "OFData.h"


#import "OFAlreadyOpenException.h"
#import "OFInitializationFailedException.h"
#import "OFNotOpenException.h"
#import "OFReadFailedException.h"
#import "OFTLSHandshakeFailedException.h"
#import "OFWriteFailedException.h"







>







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

#include "config.h"

#include <errno.h>

#import "OFOpenSSLTLSStream.h"
#import "OFData.h"
#import "OFStream+Private.h"

#import "OFAlreadyOpenException.h"
#import "OFInitializationFailedException.h"
#import "OFNotOpenException.h"
#import "OFReadFailedException.h"
#import "OFTLSHandshakeFailedException.h"
#import "OFWriteFailedException.h"
199
200
201
202
203
204
205


























206
207
208
209
210
211
212
- (bool)hasDataInReadBuffer
{
	if (SSL_pending(_SSL) > 0 || BIO_ctrl_pending(_readBIO) > 0)
		return true;

	return super.hasDataInReadBuffer;
}



























- (void)asyncPerformClientHandshakeWithHost: (OFString *)host
				runLoopMode: (OFRunLoopMode)runLoopMode
{
	static const OFTLSStreamErrorCode initFailedErrorCode =
	    OFTLSStreamErrorCodeInitializationFailed;
	id exception = nil;







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
- (bool)hasDataInReadBuffer
{
	if (SSL_pending(_SSL) > 0 || BIO_ctrl_pending(_readBIO) > 0)
		return true;

	return super.hasDataInReadBuffer;
}

- (bool)of_isWaitingForDelimiter
{
	/* FIXME: There should be a non-private API for this. */

	/*
	 * If we still have pending data in the SSL connection, we haven't
	 * processed it yet to see if our delimiter is in there. So return
	 * false here, as that will signal the stream as ready for reading,
	 * which in turn will cause a read and checking for the delimiter.
	 */
	if (SSL_pending(_SSL))
		return false;

	/*
	 * If we still have data in our read BIO, it hasn't been processed by
	 * OpenSSL yet. As we have no idea what's in there, return false to
	 * signal the stream as ready for reading, which in turn will cause a
	 * read to check for the delimiter and in turn make OpenSSL process the
	 * data in the read BIO.
	 */
	if (BIO_ctrl_pending(_readBIO) > 0)
		return false;

	return super.of_waitingForDelimiter;
}

- (void)asyncPerformClientHandshakeWithHost: (OFString *)host
				runLoopMode: (OFRunLoopMode)runLoopMode
{
	static const OFTLSStreamErrorCode initFailedErrorCode =
	    OFTLSStreamErrorCodeInitializationFailed;
	id exception = nil;