reworked Y2038 fix

This commit is contained in:
Thomas Ries 2022-01-05 16:21:16 +01:00
parent 91e041dbfc
commit 88f601c6cf
3 changed files with 9 additions and 21 deletions

View File

@ -1,5 +1,6 @@
0.8.4dev
========
05-Jan-2022: - reworked Y2038 fix
25-Oct-2021: - fixed some Y2038 issues related to 64bit time
support for 32bit plattforms
29-Jun-2021: - fix: silence_log handling - was always logging

View File

@ -72,9 +72,13 @@ void register_init(void) {
/* read the url table from file */
DEBUGC(DBCLASS_REG,"loading registration table, size=%i",URLMAP_SIZE);
for (i=0;i < URLMAP_SIZE; i++) {
int a=0;
long long e=0;
t=fgets(buff, sizeof(buff), stream);
if (t==NULL) { break;}
sts=sscanf(buff, "****:%i:%"TIME_T_INT_FMT , &urlmap[i].active, &urlmap[i].expires);
sts=sscanf(buff, "****:%i:%lld", &a, &e);
urlmap[i].active=a;
urlmap[i].expires=(time_t)e;
if (sts == 0) break; /* format error */
if (urlmap[i].active) {
#define R(X) {\
@ -146,7 +150,7 @@ void register_save(void) {
}
for (i=0;i < URLMAP_SIZE; i++) {
fprintf(stream, "****:%i:%"TIME_T_INT_FMT "\n", urlmap[i].active, urlmap[i].expires);
fprintf(stream, "****:%i:%lld\n", urlmap[i].active, (long long)urlmap[i].expires);
if (urlmap[i].active) {
#define W(X) { \
char *tmp=NULL; \
@ -336,12 +340,12 @@ int register_client(sip_ticket_t *ticket, int force_lcl_masq) {
/* check address-of-record ("public address" of user) */
if (compare_url(url1_to, url2_to)==STS_SUCCESS) {
DEBUGC(DBCLASS_REG, "found entry for %s@%s <-> %s@%s at "
"slot=%i, exp=%"TIME_T_INT_FMT,
"slot=%i, exp=%lld",
(url1_contact->username) ? url1_contact->username : "*NULL*",
(url1_contact->host) ? url1_contact->host : "*NULL*",
(url2_to->username) ? url2_to->username : "*NULL*",
(url2_to->host) ? url2_to->host : "*NULL*",
i, urlmap[i].expires-time_now);
i, (long long)(urlmap[i].expires-time_now));
break;
}
}

View File

@ -352,23 +352,6 @@ int unload_plugins(void);
#define satoi atoi /* used in libosips MSG_TEST_CODE macro ... */
#endif
/*
* Y2038 stuff (64bit time_t in 32bit C libs)
* reason:
* libc64: long int ("ld") -> 64bit
* libc32: long int ("ld") -> 32bit
* also see: https://sourceware.org/glibc/wiki/Y2038ProofnessDesign
*
* TIME_T_INT_FMT: time_t format string to use in printf/scanf
*/
#ifndef TIME_T_INT_FMT
#ifdef __USE_TIME_BITS64
#define TIME_T_INT_FMT PRId64
#else
#define TIME_T_INT_FMT "ld"
#endif
#endif
/*
* Macro that limits the frequency of this particular code
* block to no faster than every 'a' seconds. Used for logging