mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:02:45 +00:00 
			
		
		
		
	LibC: Use u32 in arc4random instead of char[4]
There's no alignment requirements on a char[4] buffer, so this was causing unaligned reads that were caught by UBSAN.
This commit is contained in:
		
							parent
							
								
									1a0eed705c
								
							
						
					
					
						commit
						74da0f24f0
					
				
					 1 changed files with 3 additions and 3 deletions
				
			
		|  | @ -1080,9 +1080,9 @@ unsigned long long strtoull(const char* str, char** endptr, int base) | |||
| // TODO: In the future, rand can be made deterministic and this not.
 | ||||
| uint32_t arc4random(void) | ||||
| { | ||||
|     char buf[4]; | ||||
|     syscall(SC_getrandom, buf, 4, 0); | ||||
|     return *(uint32_t*)buf; | ||||
|     uint32_t buf; | ||||
|     syscall(SC_getrandom, &buf, sizeof(buf), 0); | ||||
|     return buf; | ||||
| } | ||||
| 
 | ||||
| void arc4random_buf(void* buffer, size_t buffer_size) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andrew Kaster
						Andrew Kaster