Fix 32-bit overflow in mktime() when time_t is 64-bits long
When converting number of days since epoch (32-bits) to seconds, calculations using 32-bit `long` overflow for years above 2038. Solve this by casting number of days to `time_t` just before final multiplication. Signed-off-by: Freddie Chopin <freddie.chopin@gmail.com>
This commit is contained in:
		
				
					committed by
					
						 Corinna Vinschen
						Corinna Vinschen
					
				
			
			
				
	
			
			
			
						parent
						
							e928275566
						
					
				
				
					commit
					3305f35570
				
			| @@ -188,7 +188,7 @@ mktime (struct tm *tim_p) | ||||
|     } | ||||
|  | ||||
|   /* compute total seconds */ | ||||
|   tim += (days * _SEC_IN_DAY); | ||||
|   tim += (time_t)days * _SEC_IN_DAY; | ||||
|  | ||||
|   TZ_LOCK; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user