Remove g_time1() call

This is not year 2038 compliant on systems with 32-bit integers.

The call can be replaced with the standard C time() call. On
POSIX systems, time_t is guaranteed to be an integer type.
This commit is contained in:
matt335672
2024-12-04 10:12:53 +00:00
parent 54a6bf11d7
commit b02689ab44
6 changed files with 8 additions and 38 deletions
-29
View File
@@ -2045,18 +2045,6 @@ g_obj_wait(tintptr *read_objs, int rcount, tintptr *write_objs, int wcount,
void
g_random(char *data, int len)
{
#if defined(_WIN32)
int index;
srand(g_time1());
for (index = 0; index < len; index++)
{
data[index] = (char)rand(); /* rand returns a number between 0 and
RAND_MAX */
}
#else
int fd;
memset(data, 0x44, len);
@@ -2075,8 +2063,6 @@ g_random(char *data, int len)
close(fd);
}
#endif
}
/*****************************************************************************/
@@ -3777,21 +3763,6 @@ g_check_user_in_group(const char *username, int gid, int *ok)
}
#endif // HAVE_GETGROUPLIST
/*****************************************************************************/
/* returns the time since the Epoch (00:00:00 UTC, January 1, 1970),
measured in seconds.
for windows, returns the number of seconds since the machine was
started. */
int
g_time1(void)
{
#if defined(_WIN32)
return GetTickCount() / 1000;
#else
return time(0);
#endif
}
/*****************************************************************************/
/* returns the number of milliseconds since the machine was
started. */
-1
View File
@@ -393,7 +393,6 @@ int g_getgroup_info(const char *groupname, int *gid);
* Primary group of username is also checked
*/
int g_check_user_in_group(const char *username, int gid, int *ok);
int g_time1(void);
int g_time2(void);
int g_time3(void);
int g_save_to_bmp(const char *filename, char *data, int stride_bytes,
+1 -1
View File
@@ -274,7 +274,7 @@ clipboard_get_file(const char *file, int bytes)
list_add_item(g_files_list, (tintptr)cfi);
cfi->size = g_file_get_size(full_fn);
cfi->flags = CB_FILE_ATTRIBUTE_ARCHIVE;
cfi->time = (g_time1() + CB_EPOCH_DIFF) * 10000000LL;
cfi->time = (time(NULL) + CB_EPOCH_DIFF) * 10000000LL;
LOG_DEVEL(LOG_LEVEL_DEBUG, "ok filename [%s] pathname [%s] size [%d]",
cfi->filename, cfi->pathname, cfi->size);
result = 0;
+3 -3
View File
@@ -225,7 +225,7 @@ auth_check_pwd_chg(const char *user)
}
/* check if we need a pwd change */
now = g_time1();
now = time(NULL);
today = now / SECS_PER_DAY;
if (stp->sp_expire == -1)
@@ -306,7 +306,7 @@ auth_change_pwd(const char *user, const char *newpwd)
}
stp->sp_pwdp = g_strdup(hash);
today = g_time1() / SECS_PER_DAY;
today = time(NULL) / SECS_PER_DAY;
stp->sp_lstchg = today;
stp->sp_expire = today + stp->sp_max + stp->sp_inact;
fd = fopen("/etc/shadow", "rw");
@@ -377,7 +377,7 @@ auth_account_disabled(struct spwd *stp)
return 1;
}
today = g_time1() / SECS_PER_DAY;
today = time(NULL) / SECS_PER_DAY;
LOG_DEVEL(LOG_LEVEL_DEBUG, "last %ld", stp->sp_lstchg);
LOG_DEVEL(LOG_LEVEL_DEBUG, "min %ld", stp->sp_min);
+2 -2
View File
@@ -57,8 +57,8 @@ log_authfail_message(const char *username, const char *ip_addr)
{
ip_addr = "unknown";
}
LOG(LOG_LEVEL_INFO, "AUTHFAIL: user=%s ip=%s time=%d",
username, ip_addr, g_time1());
LOG(LOG_LEVEL_INFO, "AUTHFAIL: user=%s ip=%s time=%ld",
username, ip_addr, (long)time(NULL));
}
/******************************************************************************/
+2 -2
View File
@@ -674,7 +674,7 @@ session_start_wrapped(struct login_info *login_info,
sd->win_mgr = window_manager_pid;
sd->x_server = display_pid;
sd->chansrv = chansrv_pid;
sd->start_time = g_time1();
sd->start_time = time(NULL);
status = E_SCP_SCREATE_OK;
}
}
@@ -860,7 +860,7 @@ session_process_child_exit(struct session_data *sd,
}
else if (pid == sd->win_mgr)
{
int wm_wait_time = g_time1() - sd->start_time;
int wm_wait_time = time(NULL) - sd->start_time;
if (e->reason == E_PXR_STATUS_CODE && e->val == 0)
{