mirror of
				https://github.com/osmarks/ngircd.git
				synced 2025-10-30 21:42:59 +00:00 
			
		
		
		
	Add support for arc4random
If arc4random is present it will be used over the srand/rand interface. This fixes some warnings in OpenBSD-current.
This commit is contained in:
		| @@ -144,11 +144,16 @@ ngt_RandomStr(char *String, const size_t len) | ||||
| 	assert(String != NULL); | ||||
|  | ||||
| 	gettimeofday(&t, NULL); | ||||
| #ifndef HAVE_ARC4RANDOM | ||||
| 	srand((unsigned)(t.tv_usec * t.tv_sec)); | ||||
|  | ||||
| 	for (i = 0; i < len; ++i) { | ||||
| 		String[i] = chars[rand() % (sizeof(chars) - 1)]; | ||||
| 	} | ||||
| #else | ||||
| 	for (i = 0; i < len; ++i) | ||||
| 		String[i] = chars[arc4random() % (sizeof(chars) - 1)]; | ||||
| #endif | ||||
| 	String[len] = '\0'; | ||||
|  | ||||
| 	return String; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Federico G. Schwindt
					Federico G. Schwindt