Browse Source

drouting: use localtime_r() for a safer multi-thread usage

Victor Seva 5 năm trước cách đây
mục cha
commit
1fe9da8c11
1 tập tin đã thay đổi với 3 bổ sung1 xóa
  1. 3 1
      src/modules/drouting/dr_time.c

+ 3 - 1
src/modules/drouting/dr_time.c

@@ -130,10 +130,12 @@ int ac_tm_fill(ac_tm_p _atp, struct tm *_tm)
 
 int ac_tm_set_time(ac_tm_p _atp, time_t _t)
 {
+	struct tm _tm;
 	if(!_atp)
 		return -1;
 	_atp->time = _t;
-	return ac_tm_fill(_atp, localtime(&_t));
+	localtime_r(&_t, &_tm);
+	return ac_tm_fill(_atp, &_tm);
 }
 
 int ac_get_mweek(struct tm *_tm)