Module: kamailio Branch: master Commit: d780945bc9a186d54439e1258ac540cd5f7bd86d URL: https://github.com/kamailio/kamailio/commit/d780945bc9a186d54439e1258ac540cd...
Author: Victor Seva linuxmaniac@torreviejawireless.org Committer: Victor Seva linuxmaniac@torreviejawireless.org Date: 2020-05-12T14:54:04+02:00
smsops: use gmtime_r() for a safer multi-thread usage
---
Modified: src/modules/smsops/smsops_impl.c
---
Diff: https://github.com/kamailio/kamailio/commit/d780945bc9a186d54439e1258ac540cd... Patch: https://github.com/kamailio/kamailio/commit/d780945bc9a186d54439e1258ac540cd...
---
diff --git a/src/modules/smsops/smsops_impl.c b/src/modules/smsops/smsops_impl.c index 5271444039..b284d83c62 100644 --- a/src/modules/smsops/smsops_impl.c +++ b/src/modules/smsops/smsops_impl.c @@ -370,24 +370,24 @@ static int DecodePhoneNumber(char* buffer, int len, str phone) { // Generate a 7 Byte Long Time static void EncodeTime(char * buffer) { time_t ts; - struct tm * now; + struct tm now; int i = 0;
time(&ts); /* Get GMT time */ - now = gmtime(&ts); + gmtime_r(&ts, &now);
- i = now->tm_year % 100; + i = now.tm_year % 100; buffer[0] = (unsigned char)((((i % 10) << 4) | (i / 10)) & 0xff); - i = now->tm_mon + 1; + i = now.tm_mon + 1; buffer[1] = (unsigned char)((((i % 10) << 4) | (i / 10)) & 0xff); - i = now->tm_mday; + i = now.tm_mday; buffer[2] = (unsigned char)((((i % 10) << 4) | (i / 10)) & 0xff); - i = now->tm_hour; + i = now.tm_hour; buffer[3] = (unsigned char)((((i % 10) << 4) | (i / 10)) & 0xff); - i = now->tm_min; + i = now.tm_min; buffer[4] = (unsigned char)((((i % 10) << 4) | (i / 10)) & 0xff); - i = now->tm_sec; + i = now.tm_sec; buffer[5] = (unsigned char)((((i % 10) << 4) | (i / 10)) & 0xff); buffer[6] = 0; // Timezone, we use no time offset. }