Module: kamailio
Branch: master
Commit: c244381c69459b3708d3603e548fafac8321acf8
URL:
https://github.com/kamailio/kamailio/commit/c244381c69459b3708d3603e548fafa…
Author: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: 2020-05-12T14:59:13+02:00
acc: use gmtime_r() for a safer multi-thread usage
---
Modified: src/modules/acc/acc_cdr.c
---
Diff:
https://github.com/kamailio/kamailio/commit/c244381c69459b3708d3603e548fafa…
Patch:
https://github.com/kamailio/kamailio/commit/c244381c69459b3708d3603e548fafa…
---
diff --git a/src/modules/acc/acc_cdr.c b/src/modules/acc/acc_cdr.c
index 7b052440e6..d59192156a 100644
--- a/src/modules/acc/acc_cdr.c
+++ b/src/modules/acc/acc_cdr.c
@@ -141,7 +141,7 @@ static int db_write_cdr( struct dlg_cell* dialog,
long long_val;
double double_val;
char * end;
- struct tm *t;
+ struct tm t;
char cdr_time_format_buf[MAX_CDR_CORE][TIME_STR_BUFFER_SIZE];
if(acc_cdrs_table.len<=0)
@@ -191,9 +191,9 @@ static int db_write_cdr( struct dlg_cell* dialog,
}
if (acc_time_mode==4) {
VAL_TYPE(db_cdr_vals+i)=DB1_STRING;
- t = gmtime(&timeval_val.tv_sec);
+ gmtime_r(&timeval_val.tv_sec, &t);
/* Convert time_t structure to format accepted by the database */
- if (strftime(cdr_time_format_buf[i], TIME_STR_BUFFER_SIZE, TIME_STRING_FORMAT, t)
<= 0) {
+ if (strftime(cdr_time_format_buf[i], TIME_STR_BUFFER_SIZE, TIME_STRING_FORMAT,
&t) <= 0) {
cdr_time_format_buf[i][0] = '\0';
}