Commit cfaa64a
authored
fix: use gmtime_r in get_timestamp for thread safety (#655)
gmtime(3) returns a pointer to a static internal buffer shared across
all threads. In a multi-threaded decoder, concurrent calls to
get_timestamp() could race on that buffer, corrupting decoded timestamps.
gmtime_r(3) takes a caller-supplied struct tm buffer, eliminating the
race. It is already used consistently elsewhere in the codebase
(log.c, waypoint.c, encode_aprs.c, beacon.c) and the portability shim
that makes it available on all platforms is in direwolf.h.
Add a null-return guard as the FIXME comment requested.
Fixes the FIXME at decode_aprs.c line 4041.1 parent 78d6559 commit cfaa64a
1 file changed
Lines changed: 3 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4034 | 4034 | | |
4035 | 4035 | | |
4036 | 4036 | | |
4037 | | - | |
| 4037 | + | |
4038 | 4038 | | |
4039 | 4039 | | |
4040 | 4040 | | |
4041 | | - | |
4042 | | - | |
4043 | | - | |
| 4041 | + | |
| 4042 | + | |
4044 | 4043 | | |
4045 | 4044 | | |
4046 | 4045 | | |
| |||
0 commit comments