Module: kamailio
Branch: master
Commit: 14aa67d750150cf6eb588b350ce156b770d4816d
URL: 
https://github.com/kamailio/kamailio/commit/14aa67d750150cf6eb588b350ce156b770d4816d

Author: Victor Seva <[email protected]>
Committer: Victor Seva <[email protected]>
Date: 2020-05-12T15:02:50+02:00

xhttp_rpc: use gmtime_r() for a safer multi-thread usage

---

Modified: src/modules/xhttp_rpc/xhttp_rpc.c

---

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

---

diff --git a/src/modules/xhttp_rpc/xhttp_rpc.c 
b/src/modules/xhttp_rpc/xhttp_rpc.c
index e51ff838bf..b9269c294d 100644
--- a/src/modules/xhttp_rpc/xhttp_rpc.c
+++ b/src/modules/xhttp_rpc/xhttp_rpc.c
@@ -283,7 +283,7 @@ static int print_value(rpc_ctx_t* ctx, char fmt, va_list* 
ap, str *id)
        str *sp;
        char buf[PRINT_VALUE_BUF_LEN];
        time_t dt;
-       struct tm* t;
+       struct tm t;
 
        switch(fmt) {
        case 'd':
@@ -306,9 +306,9 @@ static int print_value(rpc_ctx_t* ctx, char fmt, va_list* 
ap, str *id)
                body.s = buf;
                body.len = sizeof("19980717T14:08:55") - 1;
                dt = va_arg(*ap, time_t);
-               t = gmtime(&dt);
+               gmtime_r(&dt, &t);
                if (strftime(buf, PRINT_VALUE_BUF_LEN,
-                               "%Y%m%dT%H:%M:%S", t) == 0) {
+                               "%Y%m%dT%H:%M:%S", &t) == 0) {
                        LM_ERR("Error while converting time\n");
                        return -1;
                }


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

Reply via email to