ObjFW  Check-in [daf78156a7]

Overview
Comment:Check <= SSIZE_MAX before assignign to ssize_t
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: daf78156a7b85f1ec4028665135c6b2b960b921d10e31a2c34434a1fcac7f972
User & Date: js on 2015-05-03 11:34:12
Other Links: manifest | tags
Context
2015-05-03
11:46
OFAddressTranslationFailedException: Fix #ifdefs check-in: 050b7af83a user: js tags: trunk
11:34
Check <= SSIZE_MAX before assignign to ssize_t check-in: daf78156a7 user: js tags: trunk
10:16
OFTCPSocket: Add -[setTCPNoDelayEnabled:] check-in: 12fbe85aab user: js tags: trunk
Changes

Modified src/OFMutableString.m from [5097d3765b] to [4a0b7f4d80].

523
524
525
526
527
528
529



530
531
532
533
534
535
536
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539







+
+
+







}

- (void)deleteTrailingWhitespaces
{
	size_t length = [self length];
	ssize_t i;

	if (length - 1 > SSIZE_MAX)
		@throw [OFOutOfRangeException exception];

	for (i = length - 1; i >= 0; i--) {
		of_unichar_t c = [self characterAtIndex: i];

		if (c != ' '  && c != '\t' && c != '\n' && c != '\r' &&
		    c != '\f')
			break;
	}

Modified src/OFString.m from [3315fcda12] to [ef29c8b8a2].

2000
2001
2002
2003
2004
2005
2006



2007
2008
2009
2010
2011
2012
2013
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016







+
+
+








	if (length == 0) {
		objc_autoreleasePoolPop(pool);

		return @"";
	}

	if (length - 1 > SSIZE_MAX)
		@throw [OFOutOfRangeException exception];

	for (i = length - 1; i >= 0; i--) {
		if (OF_IS_PATH_DELIMITER(characters[i])) {
			i++;
			break;
		}
	}

Modified src/OFString_UTF8.m from [f9a61670cf] to [30daa260be].

1127
1128
1129
1130
1131
1132
1133



1134
1135
1136
1137
1138
1139
1140
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143







+
+
+








	if (OF_IS_PATH_DELIMITER(_s->cString[pathCStringLength - 1]))
		pathCStringLength--;

	if (pathCStringLength == 0)
		return @"";

	if (pathCStringLength - 1 > SSIZE_MAX)
		@throw [OFOutOfRangeException exception];

	for (i = pathCStringLength - 1; i >= 0; i--) {
		if (OF_IS_PATH_DELIMITER(_s->cString[i])) {
			i++;
			break;
		}
	}

Modified src/OFXMLParser.m from [d18eed8a23] to [3e706b5d43].

31
32
33
34
35
36
37

38
39
40
41
42
43
44
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45







+







# import "OFFile.h"
#endif
#import "OFSystemInfo.h"

#import "OFInitializationFailedException.h"
#import "OFInvalidFormatException.h"
#import "OFMalformedXMLException.h"
#import "OFOutOfRangeException.h"
#import "OFUnboundPrefixException.h"

typedef void (*state_function_t)(id, SEL);
static SEL selectors[OF_XMLPARSER_NUM_STATES];
static state_function_t lookupTable[OF_XMLPARSER_NUM_STATES];

static OF_INLINE void
100
101
102
103
104
105
106

107
108
109
110
111



112

113
114
115
116
117
118
119
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116

117
118
119
120
121
122
123
124







+





+
+
+
-
+







	return ret;
}

static OFString*
namespaceForPrefix(OFString *prefix, OFArray *namespaces)
{
	OFDictionary *const *objects = [namespaces objects];
	size_t count = [namespaces count];
	ssize_t i;

	if (prefix == nil)
		prefix = @"";

	if (count - 1 > SSIZE_MAX)
		@throw [OFOutOfRangeException exception];

	for (i = [namespaces count] - 1; i >= 0; i--) {
	for (i = count - 1; i >= 0; i--) {
		OFString *tmp;

		if ((tmp = [objects[i] objectForKey: prefix]) != nil)
			return tmp;
	}

	return nil;