ObjFW  Diff

Differences From 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]

To Artifact [58de981563]:


125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
		    &cancelAddrLen))
			@throw [OFInitializationFailedException
			    newWithClass: isa];
#endif

		maxFD = cancelFD[0];
		FDToStream = [self allocMemoryForNItems: maxFD + 1
					       withSize: sizeof(OFStream*)];
		FDToStream[cancelFD[0]] = nil;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;







|







125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
		    &cancelAddrLen))
			@throw [OFInitializationFailedException
			    newWithClass: isa];
#endif

		maxFD = cancelFD[0];
		FDToStream = [self allocMemoryForNItems: maxFD + 1
						 ofSize: sizeof(OFStream*)];
		FDToStream[cancelFD[0]] = nil;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
				int fd = [queueCArray[i] fileDescriptor];

				if (fd > maxFD) {
					maxFD = fd;
					FDToStream = [self
					    resizeMemory: FDToStream
						toNItems: maxFD + 1
						withSize: sizeof(OFStream*)];
				}

				FDToStream[fd] = queueCArray[i];
			}

			if ((action & QUEUE_ACTION) == QUEUE_REMOVE) {
				int fd = [queueCArray[i] fileDescriptor];







|







281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
				int fd = [queueCArray[i] fileDescriptor];

				if (fd > maxFD) {
					maxFD = fd;
					FDToStream = [self
					    resizeMemory: FDToStream
						toNItems: maxFD + 1
						  ofSize: sizeof(OFStream*)];
				}

				FDToStream[fd] = queueCArray[i];
			}

			if ((action & QUEUE_ACTION) == QUEUE_REMOVE) {
				int fd = [queueCArray[i] fileDescriptor];