mirror of
https://github.com/wolfcw/libfaketime.git
synced 2026-05-17 00:26:16 +03:00
macos: pass one gettimeofday unmodified
needed to avoid a malloc recursion; dyld calls the libSystem initializer, which calls malloc as the first caller; that uses the arc4 randomizer, which calls gettimeofday... the call to fake_time calls strptime_l, _strptime0, gmtsub, and boom, back at malloc. pass one gettimeofday call to let the malloc succeed.
This commit is contained in:
@@ -630,6 +630,9 @@ time_t fake_time(time_t *time_tptr) {
|
||||
static time_t last_data_fetch = 0; /* not fetched previously at first call */
|
||||
static int cache_expired = 1; /* considered expired at first call */
|
||||
static int cache_duration = 10; /* cache fake time input for 10 seconds */
|
||||
#ifdef __APPLE__
|
||||
static int malloc_arena = 0;
|
||||
#endif
|
||||
|
||||
#ifdef PTHREAD_SINGLETHREADED_TIME
|
||||
static pthread_mutex_t time_mutex=PTHREAD_MUTEX_INITIALIZER;
|
||||
@@ -699,6 +702,13 @@ static pthread_mutex_t time_mutex=PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
} /* cache had expired */
|
||||
|
||||
#ifdef __APPLE__
|
||||
SINGLE_IF(malloc_arena==0)
|
||||
malloc_arena = 1;
|
||||
return *time_tptr;
|
||||
END_SINGLE_IF
|
||||
#endif
|
||||
|
||||
/* check whether the user gave us an absolute time to fake */
|
||||
switch (user_faked_time[0]) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user