ObjFW  Check-in [7c2a0dda3d]

Overview
Comment:Do not include any addresses in -[description]

This makes it harder to accidentally leak addresses which could be used
to defeat ASLR.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 7c2a0dda3d620a174573619723fa77253d57c1d16977441d03f4896616829beb
User & Date: js on 2017-05-07 15:39:31
Other Links: manifest | tags
Context
2017-05-07
20:10
Small code style change check-in: 4af49a13c3 user: js tags: trunk
15:39
Do not include any addresses in -[description] check-in: 7c2a0dda3d user: js tags: trunk
15:01
OFHTTPClient: Minor change to improve readability check-in: 8066257442 user: js tags: trunk
Changes

Modified src/OFHTTPResponse.m from [e0037e3e3d] to [ae2e00de64].

240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
	OFString *indentedHeaders, *ret;

	indentedHeaders = [[_headers description]
	    stringByReplacingOccurrencesOfString: @"\n"
				      withString: @"\n\t"];

	ret = [[OFString alloc] initWithFormat:
	    @"<%@: %p\n"
	    @"\tStatus code = %d\n"
	    @"\tHeaders = %@\n"
	    @">",
	    [self class], self, _statusCode, indentedHeaders];

	objc_autoreleasePoolPop(pool);

	return [ret autorelease];
}
@end







|



|






240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
	OFString *indentedHeaders, *ret;

	indentedHeaders = [[_headers description]
	    stringByReplacingOccurrencesOfString: @"\n"
				      withString: @"\n\t"];

	ret = [[OFString alloc] initWithFormat:
	    @"<%@:\n"
	    @"\tStatus code = %d\n"
	    @"\tHeaders = %@\n"
	    @">",
	    [self class], _statusCode, indentedHeaders];

	objc_autoreleasePoolPop(pool);

	return [ret autorelease];
}
@end

Modified src/OFObject.m from [8d7351b7a0] to [3768fd3a96].

818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
	return hash;
}

- (OFString*)description
{
	/* Classes containing data should reimplement this! */

	return [OFString stringWithFormat: @"<%@: %p>", [self className], self];
}

- (void*)allocMemoryWithSize: (size_t)size
{
	void *pointer;
	struct pre_mem *preMem;








|







818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
	return hash;
}

- (OFString*)description
{
	/* Classes containing data should reimplement this! */

	return [OFString stringWithFormat: @"<%@>", [self className]];
}

- (void*)allocMemoryWithSize: (size_t)size
{
	void *pointer;
	struct pre_mem *preMem;

Modified src/OFTarArchiveEntry.m from [1425c945d2] to [4e294b0368].

180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
		[_stream readIntoBuffer: buffer
			    exactLength: 512 - ((size_t)_size % 512)];
}

- (OFString*)description
{
	void *pool = objc_autoreleasePoolPush();
	OFString *ret = [OFString stringWithFormat: @"<%@: %p\n"
	     @"\tFile name = %@\n"
	     @"\tMode = %06o\n"
	     @"\tSize = %" PRIu64 @"\n"
	     @"\tModification date = %@\n"
	     @"\tType = %u\n"
	     @"\tTarget file name = %@\n"
	     @"\tOwner = %@\n"
	     @"\tGroup = %@\n"
	     @"\tDevice major = %" PRIu32 @"\n"
	     @"\tDevice minor = %" PRIu32 @"\n"
	     @">",
	    [self class], self, _fileName, _mode, _size, _modificationDate,
	    _type, _targetFileName, _owner, _group, _deviceMajor, _deviceMinor];

	[ret retain];

	objc_autoreleasePoolPop(pool);

	return [ret autorelease];
}







|











|
|







180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
		[_stream readIntoBuffer: buffer
			    exactLength: 512 - ((size_t)_size % 512)];
}

- (OFString*)description
{
	void *pool = objc_autoreleasePoolPush();
	OFString *ret = [OFString stringWithFormat: @"<%@:\n"
	     @"\tFile name = %@\n"
	     @"\tMode = %06o\n"
	     @"\tSize = %" PRIu64 @"\n"
	     @"\tModification date = %@\n"
	     @"\tType = %u\n"
	     @"\tTarget file name = %@\n"
	     @"\tOwner = %@\n"
	     @"\tGroup = %@\n"
	     @"\tDevice major = %" PRIu32 @"\n"
	     @"\tDevice minor = %" PRIu32 @"\n"
	     @">",
	    [self class], _fileName, _mode, _size, _modificationDate, _type,
	    _targetFileName, _owner, _group, _deviceMajor, _deviceMinor];

	[ret retain];

	objc_autoreleasePoolPop(pool);

	return [ret autorelease];
}

Modified src/OFZIPArchiveEntry.m from [f98ed34051] to [75090f7155].

265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
{
	return [[_extraField copy] autorelease];
}

- (OFString*)description
{
	void *pool = objc_autoreleasePoolPush();
	OFString *ret = [OFString stringWithFormat: @"<%@: %p\n"
	    @"\tFile name = %@\n"
	    @"\tFile comment = %@\n"
	    @"\tGeneral purpose bit flag = %u\n"
	    @"\tCompression method = %u\n"
	    @"\tCompressed size = %ju\n"
	    @"\tUncompressed size = %ju\n"
	    @"\tModification date = %@\n"
	    @"\tCRC32 = %" @PRIu32 @"\n"
	    @"\tExtra field = %@\n"
	    @">",
	    [self class], self, _fileName, _fileComment, _generalPurposeBitFlag,
	    _compressionMethod, (intmax_t)_compressedSize,
	    (intmax_t)_uncompressedSize, [self modificationDate], _CRC32,
	    _extraField];

	[ret retain];

	objc_autoreleasePoolPop(pool);







|










|







265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
{
	return [[_extraField copy] autorelease];
}

- (OFString*)description
{
	void *pool = objc_autoreleasePoolPush();
	OFString *ret = [OFString stringWithFormat: @"<%@:\n"
	    @"\tFile name = %@\n"
	    @"\tFile comment = %@\n"
	    @"\tGeneral purpose bit flag = %u\n"
	    @"\tCompression method = %u\n"
	    @"\tCompressed size = %ju\n"
	    @"\tUncompressed size = %ju\n"
	    @"\tModification date = %@\n"
	    @"\tCRC32 = %" @PRIu32 @"\n"
	    @"\tExtra field = %@\n"
	    @">",
	    [self class], _fileName, _fileComment, _generalPurposeBitFlag,
	    _compressionMethod, (intmax_t)_compressedSize,
	    (intmax_t)_uncompressedSize, [self modificationDate], _CRC32,
	    _extraField];

	[ret retain];

	objc_autoreleasePoolPop(pool);

Modified src/exceptions/OFMemoryNotPartOfObjectException.m from [9e52939923] to [0b7ef4c480].

51
52
53
54
55
56
57
58
59
60
61
62
63

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Memory at %p was not allocated as part of object of type %@, "
	    @"thus the memory allocation was not changed! It is also possible "
	    @"that there was an attempt to free the same memory twice.",
	    _pointer, [_object class]];
}
@end







|
|
|
|


51
52
53
54
55
56
57
58
59
60
61
62
63

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Deallocation or reallocation of memory not allocated as part of "
	    @"object of type %@ was attempted! It is also possible that there "
	    @"was an attempt to free the same memory twice.",
	    [_object class]];
}
@end

Modified tests/OFObjectTests.m from [e9d766fa55] to [2156cf6ce1].

143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
	    [[OFObject description] isEqual: @"OFObject"] &&
	    [[MyObj description] isEqual: @"MyObj"])

	o = [[[OFObject alloc] init] autorelease];
	m = [[[MyObj alloc] init] autorelease];

	TEST(@"-[description]",
	    [[o description] isEqual:
	    [OFString stringWithFormat: @"<OFObject: %p>", o]] &&
	    [[m description] isEqual:
	    [OFString stringWithFormat: @"<MyObj: %p>", m]])

	[m setObjectValue: @"Hello"];
	[m setClassValue: [m class]];
	TEST(@"-[valueForKey:]",
	    [[m valueForKey: @"objectValue"] isEqual: @"Hello"] &&
	    [[m valueForKey: @"classValue"] isEqual: [m class]] &&
	    [[m valueForKey: @"class"] isEqual: [m class]])







|
<
|
<







143
144
145
146
147
148
149
150

151

152
153
154
155
156
157
158
	    [[OFObject description] isEqual: @"OFObject"] &&
	    [[MyObj description] isEqual: @"MyObj"])

	o = [[[OFObject alloc] init] autorelease];
	m = [[[MyObj alloc] init] autorelease];

	TEST(@"-[description]",
	    [[o description] isEqual: @"<OFObject>"] &&

	    [[m description] isEqual: @"<MyObj>"])


	[m setObjectValue: @"Hello"];
	[m setClassValue: [m class]];
	TEST(@"-[valueForKey:]",
	    [[m valueForKey: @"objectValue"] isEqual: @"Hello"] &&
	    [[m valueForKey: @"classValue"] isEqual: [m class]] &&
	    [[m valueForKey: @"class"] isEqual: [m class]])