ObjFW  Diff

Differences From Artifact [8a0142f57a]:

To Artifact [920a5b1adb]:

  • File src/OFObject.m — part of check-in [50e4ae0716] at 2015-08-26 08:50:09 on branch trunk — Make sure of_hash_seed is never initialized to 0

    of_hash_seed == 0 is special, as it means to OFMapTable to behave
    deterministically (which is required for the tests, for example) and not
    do any random per-hashtable rotating on the hash. The random rotation
    improves resistance against hash collision DoS attacks, so if the random
    seed happens to be 0, it would disable that rotation unintentionally,
    thus it's better to get a new random seed if it is 0. (user: js, size: 24525) [annotate] [blame] [check-ins using] [more...]


226
227
228
229
230
231
232


233
234
235
236
237
238
239

240
241
242
243
244
245

246
247
248
249
250
251
252
	objc_setForwardHandler((IMP)&of_forward, (IMP)&of_forward_stret);
#endif

#ifdef HAVE_OBJC_ENUMERATIONMUTATION
	objc_setEnumerationMutationHandler(enumerationMutationHandler);
#endif



#if defined(HAVE_ARC4RANDOM)
	of_hash_seed = arc4random();
#elif defined(HAVE_RANDOM)
	struct timeval t;
	gettimeofday(&t, NULL);
	srandom((unsigned)(t.tv_sec ^ t.tv_usec));
	of_hash_seed = (uint32_t)((random() << 16) | (random() & 0xFFFF));

#else
	struct timeval t;
	gettimeofday(&t, NULL);
	srand((unsigned)(t.tv_sec ^ t.tv_usec));
	of_hash_seed = (uint32_t)((rand() << 16) | (rand() & 0xFFFF));
#endif

}

+ (void)unload
{
}

+ (void)initialize







>
>

|

|
|
|
|
>

|
|
|
|

>







226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
	objc_setForwardHandler((IMP)&of_forward, (IMP)&of_forward_stret);
#endif

#ifdef HAVE_OBJC_ENUMERATIONMUTATION
	objc_setEnumerationMutationHandler(enumerationMutationHandler);
#endif

	of_hash_seed = 0;
	while (of_hash_seed == 0) {
#if defined(HAVE_ARC4RANDOM)
		of_hash_seed = arc4random();
#elif defined(HAVE_RANDOM)
		struct timeval t;
		gettimeofday(&t, NULL);
		srandom((unsigned)(t.tv_sec ^ t.tv_usec));
		of_hash_seed = (uint32_t)((random() << 16) |
		    (random() & 0xFFFF));
#else
		struct timeval t;
		gettimeofday(&t, NULL);
		srand((unsigned)(t.tv_sec ^ t.tv_usec));
		of_hash_seed = (uint32_t)((rand() << 16) | (rand() & 0xFFFF));
#endif
	}
}

+ (void)unload
{
}

+ (void)initialize