mirror of
				https://github.com/Mbed-TLS/mbedtls.git
				synced 2025-11-03 20:33:16 +03:00 
			
		
		
		
	mbedtls_x509_time_gmtime() read struct directly
Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
This commit is contained in:
		
				
					committed by
					
						
						David Horstmann
					
				
			
			
				
	
			
			
			
						parent
						
							61d99304da
						
					
				
				
					commit
					811eeb21d8
				
			@@ -1013,23 +1013,19 @@ int mbedtls_x509_time_cmp(const mbedtls_x509_time *t1,
 | 
				
			|||||||
#if defined(MBEDTLS_HAVE_TIME_DATE)
 | 
					#if defined(MBEDTLS_HAVE_TIME_DATE)
 | 
				
			||||||
int mbedtls_x509_time_gmtime(mbedtls_time_t tt, mbedtls_x509_time *now)
 | 
					int mbedtls_x509_time_gmtime(mbedtls_time_t tt, mbedtls_x509_time *now)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    struct tm *lt, tm_buf;
 | 
					    struct tm tm;
 | 
				
			||||||
    int ret = 0;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    lt = mbedtls_platform_gmtime_r(&tt, &tm_buf);
 | 
					    if (mbedtls_platform_gmtime_r(&tt, &tm) == NULL) {
 | 
				
			||||||
 | 
					        return -1;
 | 
				
			||||||
    if (lt == NULL) {
 | 
					 | 
				
			||||||
        ret = -1;
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
        now->year = lt->tm_year + 1900;
 | 
					 | 
				
			||||||
        now->mon  = lt->tm_mon  + 1;
 | 
					 | 
				
			||||||
        now->day  = lt->tm_mday;
 | 
					 | 
				
			||||||
        now->hour = lt->tm_hour;
 | 
					 | 
				
			||||||
        now->min  = lt->tm_min;
 | 
					 | 
				
			||||||
        now->sec  = lt->tm_sec;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return ret;
 | 
					    now->year = tm.tm_year + 1900;
 | 
				
			||||||
 | 
					    now->mon  = tm.tm_mon  + 1;
 | 
				
			||||||
 | 
					    now->day  = tm.tm_mday;
 | 
				
			||||||
 | 
					    now->hour = tm.tm_hour;
 | 
				
			||||||
 | 
					    now->min  = tm.tm_min;
 | 
				
			||||||
 | 
					    now->sec  = tm.tm_sec;
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int x509_get_current_time(mbedtls_x509_time *now)
 | 
					static int x509_get_current_time(mbedtls_x509_time *now)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user