Module: kamailio
Branch: 5.3
Commit: ac3fe062bd9b429133ab086fc28e15b97421a092
URL: 
https://github.com/kamailio/kamailio/commit/ac3fe062bd9b429133ab086fc28e15b97421a092

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2020-05-06T12:01:02+02:00

libs/srdb1: use thread safe localtime_r()

(cherry picked from commit c01633dc54d8d4dc3b3bc2cab064f91a49c8257d)

---

Modified: src/lib/srdb1/db_ut.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/ac3fe062bd9b429133ab086fc28e15b97421a092.diff
Patch: 
https://github.com/kamailio/kamailio/commit/ac3fe062bd9b429133ab086fc28e15b97421a092.patch

---

diff --git a/src/lib/srdb1/db_ut.c b/src/lib/srdb1/db_ut.c
index 39ac11d379..318b442e44 100644
--- a/src/lib/srdb1/db_ut.c
+++ b/src/lib/srdb1/db_ut.c
@@ -350,7 +350,7 @@ int db_str2time(const char* _s, time_t* _v)
  */
 int db_time2str_ex(time_t _v, char* _s, int* _l, int _qmode)
 {
-       struct tm* t;
+       struct tm t;
        int l;
 
        if ((!_s) || (!_l) || (*_l < 2)) {
@@ -361,8 +361,8 @@ int db_time2str_ex(time_t _v, char* _s, int* _l, int _qmode)
        if(_qmode) *_s++ = '\'';
 
        /* Convert time_t structure to format accepted by the database */
-       t = localtime(&_v);
-       l = strftime(_s, *_l -1, "%Y-%m-%d %H:%M:%S", t);
+       localtime_r(&_v, &t);
+       l = strftime(_s, *_l -1, "%Y-%m-%d %H:%M:%S", &t);
 
        if (l == 0) {
                LM_ERR("Error during time conversion\n");


_______________________________________________
Kamailio (SER) - Development Mailing List
[email protected]
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to