Skip to content

Commit

Permalink
xhttp_rpc: use gmtime_r() for a safer multi-thread usage
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxmaniac committed May 12, 2020
1 parent c244381 commit 14aa67d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/modules/xhttp_rpc/xhttp_rpc.c
Expand Up @@ -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':
Expand All @@ -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;
}
Expand Down

0 comments on commit 14aa67d

Please sign in to comment.