ObjFW  Diff

Differences From Artifact [26a8940bc6]:

To Artifact [332048c7be]:

  • File src/OFStreamObserver.m — part of check-in [535c2d5d9b] at 2011-09-19 16:22:23 on branch trunk — Make using -[tryReadLine] + OFStreamObserver safe.

    This makes it impossible for the developer to accidentally create a DoS.
    When data has been received after calling -[tryReadLine] and the string
    is still incomplete, -[streamIsReadyForReading:] will not be called
    anymore until new data has been received, thus preventing spinning in a
    loop. (user: js, size: 8431) [annotate] [blame] [check-ins using]


352
353
354
355
356
357
358
359


360
361
362
363
364
365
366
352
353
354
355
356
357
358

359
360
361
362
363
364
365
366
367







-
+
+







	OFStream **cArray = [readStreams cArray];
	size_t i, count = [readStreams count];
	BOOL foundInCache = NO;

	pool = [[OFAutoreleasePool alloc] init];

	for (i = 0; i < count; i++) {
		if ([cArray[i] pendingBytes] > 0) {
		if ([cArray[i] pendingBytes] > 0 &&
		    ![cArray[i] _isWaitingForDelimiter]) {
			[delegate streamIsReadyForReading: cArray[i]];
			foundInCache = YES;
			[pool releaseObjects];
		}
	}

	[pool release];