ObjFW  Check-in [e6c5c90751]

Overview
Comment:Remove strlen in -[appendCStringWithoutUTF8Checking:length:].

When passing a string without \0-termination, strlen would access the
passed string out of bounds.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e6c5c907510f150925b003bedbca77c9c8a43e78249b6d8490bf0a0ac5eaab8e
User & Date: js on 2010-11-17 16:06:19
Other Links: manifest | tags
Context
2010-11-17
18:27
Adjust type to recent changes in -[OFArray componentsJoinedByString].
Not a problem, but changing it makes it clearer.
check-in: 5fe7a098d5 user: js tags: trunk
16:06
Remove strlen in -[appendCStringWithoutUTF8Checking:length:]. check-in: e6c5c90751 user: js tags: trunk
13:05
Ensure we have an OFMutableString in -[OFArray description]. check-in: ea2533ca8e user: js tags: trunk
Changes

Modified src/OFMutableString.m from [b3b5f8f9a0] to [bb152a87a3].

200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
	memcpy(string + length, str, strlength + 1);
	length += strlength;
}

- (void)appendCStringWithoutUTF8Checking: (const char*)str
				  length: (size_t)len
{
	if (len > strlen(str))
		@throw [OFOutOfRangeException newWithClass: isa];

	string = [self resizeMemory: string
			     toSize: length + len + 1];
	memcpy(string + length, str, len);
	length += len;
	string[length] = 0;
}








<
<
<







200
201
202
203
204
205
206



207
208
209
210
211
212
213
	memcpy(string + length, str, strlength + 1);
	length += strlength;
}

- (void)appendCStringWithoutUTF8Checking: (const char*)str
				  length: (size_t)len
{



	string = [self resizeMemory: string
			     toSize: length + len + 1];
	memcpy(string + length, str, len);
	length += len;
	string[length] = 0;
}