ObjFW  Check-in [19df6b304d]

Overview
Comment:OFStreamObserver_kqueue: Integer overflow check.

This is only relevant for platforms on which kqueue uses int for the
number of events instead of size_t.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 19df6b304d29223f2a839b71fa5b030f3c2643f9bc506d5e794f622c40855eeb
User & Date: js on 2012-12-11 23:26:49
Other Links: manifest | tags
Context
2012-12-12
18:40
Coding style. check-in: 6ad5d3d8d6 user: js tags: trunk
2012-12-11
23:26
OFStreamObserver_kqueue: Integer overflow check. check-in: 19df6b304d user: js tags: trunk
16:38
OFHTTPRequest: Add the current date if necessary. check-in: d330801ded user: js tags: trunk
Changes

Modified src/OFStreamObserver_kqueue.m from [8827a4d942] to [1e1bf29b71].

26
27
28
29
30
31
32

33
34
35
36
37
38
39
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40







+







#include <sys/time.h>

#import "OFStreamObserver_kqueue.h"
#import "OFDataArray.h"

#import "OFInitializationFailedException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"

#import "autorelease.h"
#import "macros.h"

#define EVENTLIST_SIZE 64

@implementation OFStreamObserver_kqueue
66
67
68
69
70
71
72



73
74
75
76
77
78
79
80



81
82
83
84
85
86
87
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94







+
+
+








+
+
+







	[super dealloc];
}

- (void)OF_addFileDescriptorForReading: (int)fd
{
	struct kevent event;

	if ([changeList count] >= INT_MAX)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	EV_SET(&event, fd, EVFILT_READ, EV_ADD, 0, 0, 0);
	[changeList addItem: &event];
}

- (void)OF_addFileDescriptorForWriting: (int)fd
{
	struct kevent event;

	if ([changeList count] >= INT_MAX)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	EV_SET(&event, fd, EVFILT_WRITE, EV_ADD, 0, 0, 0);
	[changeList addItem: &event];
}

- (void)OF_removeFileDescriptorForReading: (int)fd
{
	struct kevent event;