Debian Codegraph @

NEWS

raw
1 librist - Reliable Internet Stream Transport
2 ============================================
3
4 A library implementing the Video Services Forum (VSF) Technical
5 Recommendations TR-06-1 (Simple Profile), TR-06-2 (Main Profile),
6 and TR-06-3 (Advanced Profile).
7
8
9 Changes for 0.2.18:
10 ---------------------------------
11
12 ABI/API:
13 - ABI version 15:0:11 (soversion 4, binary-compatible with 0.2.15,
14 0.2.16, and 0.2.17)
15 - API version 4.12.0 (new features, backwards-compatible)
16 - RIST_PEER_CONFIG_VERSION bumped from 2 to 3 (one new field:
17 srp_compat_legacy). Existing zero-initialised peer configs
18 continue to work; the new field defaults to 0 (spec-compliant).
19 - RIST_PEER_CONFIG_VERSION bumped from 3 to 4 (two new fields:
20 profile + profile_set, populated by the ?profile= URL parameter).
21 rist_peer_config_defaults_set() initialises both to safe defaults
22 (profile = RIST_DEFAULT_PROFILE, profile_set = 0). Existing
23 zero-initialised configs keep their pre-bump behaviour.
24 - New rist_peer_config_defaults_set_versioned(cfg, version) initialises
25 only the fields defined at or below the given RIST_PEER_CONFIG_VERSION.
26 rist_peer_config_defaults_set() is now a static inline wrapper (peer.h)
27 that forwards the caller's compiled RIST_PEER_CONFIG_VERSION, so a
28 recompiled caller initialises exactly the fields its struct contains.
29 The exported rist_peer_config_defaults_set() symbol is retained for
30 binaries linked against an earlier library; it assumes version 0 and
31 sets only the baseline fields present in every struct revision. Such
32 binaries must zero-initialise their config before the call: fields
33 added in version 1+ (split_mode, merge_mode, profile, profile_set)
34 are left untouched.
35 - RIST_PEER_CONFIG_VERSION bumped from 4 to 5 (two new fields:
36 recovery_priority, populated by the ?recovery-priority= URL
37 parameter, and recovery_depth, populated by ?recovery-depth=).
38 rist_peer_config_defaults_set_versioned() initialises them for
39 callers compiled against version 5 or later (recovery_priority = 0,
40 recovery_depth = RIST_RECOVERY_DEPTH_DEFAULT); zero-initialised
41 configs and callers built against an earlier version keep the legacy
42 NACK-routing behaviour and the default recovery ring.
43 - New public API rist_recovery_depth_set(ctx, depth) and the
44 RIST_RECOVERY_DEPTH_MIN/DEFAULT/MAX macros (peer.h) size the
45 Advanced-profile retransmission ring. depth is a base-2 exponent:
46 the ring holds 65536 << depth packets (default 3 = 8x = the prior
47 fixed size, range 0..16). Must be called before rist_start().
48 - New public macro RIST_PEER_WEIGHT_DUPLICATE (0) names the
49 rist_peer_config.weight sentinel that selects packet duplication
50 instead of weighted load-balancing. Value unchanged.
51 - RIST_STATS_VERSION bumped from 2 to 3 and the JSON stats
52 schema_version from 3 to 4 (additive): rist_stats_sender_peer gains
53 profile + advanced_active, rist_stats_receiver_flow gains profile +
54 seq_bits + advanced_active. Consumers reading only earlier fields are
55 unaffected.
56
57 Features:
58 - Per-peer retransmission routing: the new ?recovery-priority=<n>
59 peer URL parameter (rist_peer_config.recovery_priority) lets a
60 receiver direct NACKs to a chosen peer when a flow is carried by
61 more than one RTCP-capable peer. Each NACK group is sent to the
62 eligible peer with the highest recovery_priority, ties broken by
63 lowest RTT. The default of 0 on every peer preserves the prior
64 lowest-RTT selection. Useful when the lowest-RTT peer cannot
65 answer NACKs (e.g. a duplicate/relay feed with no retransmit
66 buffer) while a higher-RTT peer holds the retransmission buffer.
67 - Tunable Advanced-profile recovery depth: the recovery rings are now
68 heap-allocated and profile-sized, so Simple/Main flows allocate only
69 their 16-bit ring (65536 packets) instead of the Advanced footprint.
70 The Advanced ring size is selectable via ?recovery-depth=N (or
71 rist_recovery_depth_set()), where N is a base-2 exponent and the ring
72 holds 65536 << N packets. The default of 3 (524288 packets) matches
73 the previous fixed size; higher values trade RAM for a deeper NACK
74 window. Simple/Main ignore the knob. A config-time warning is
75 emitted when a peer's bitrate and buffer settings would exceed the
76 recovery ring's addressable window.
77 - Advanced/Main profile interoperability (TR-06-3 Section 9): an
78 Advanced sender starts in Main framing and upgrades a peer to
79 Advanced framing only after that peer advertises Advanced capability,
80 so a Main-only receiver can still decode the stream. An Advanced
81 receiver accepts a Main-framed source and follows a mid-stream
82 Main->Advanced upgrade. Matched Advanced and matched Main pairs are
83 unchanged.
84 - The default RIST profile is now Advanced (RIST_DEFAULT_PROFILE, and
85 the ristsender/ristreceiver/YAML defaults that follow it), changed
86 from Main. Thanks to the interop above, a default Advanced endpoint
87 negotiates Advanced framing with an Advanced peer and falls back to
88 Main framing with a Main-only peer, so existing Main deployments keep
89 working. Pass -p 1 (or profile: 1 in YAML) to force Main as before.
90 - risttunnel now defaults to RIST_DEFAULT_PROFILE like the other tools,
91 instead of remaining hardcoded to Main, completing the default-profile
92 sweep.
93 - Advanced-profile visibility in statistics: the binary stats API and the
94 JSON stats now report each flow's configured profile and, on the
95 receiver, whether Advanced framing is actually active and the sequence
96 width in use. The Prometheus exporter adds rist_client_flow_info /
97 rist_sender_peer_info series carrying these labels, so a dashboard can
98 tell at a glance when it is monitoring an Advanced stream.
99
100 Bug Fixes:
101 - Advanced profile: a sequence gap larger than 65535 is no longer
102 truncated to 16 bits, so a real >64k loss on a 32-bit flow is recovered
103 instead of being mis-detected as a tiny gap.
104 - Advanced profile: receiver_mark_missing() now masks the sequence into the
105 retransmission ring index. A 32-bit sequence eventually exceeds the ring
106 size; the old raw index ran off the array and could crash the receiver on
107 a long-running Advanced flow.
108 - The expected-next-sequence wrap mask no longer forces the value even (it
109 masked with UINT16_MAX-1), which mis-computed every odd successor on
110 16-bit flows.
111 - Advanced byte accounting now counts delivered payload only, matching the
112 Simple/Main convention, so received-byte and bitrate stats are consistent
113 across profiles.
114 - Duplicate detection compares the sequence number rather than the source
115 timestamp, fixing false duplicate decisions on Advanced arrival-stamped
116 packets.
117 - Merge-mode pairing computes the successor sequence in a 32-bit-safe way,
118 so paired packets are matched correctly on Advanced flows.
119 - Advanced Profile (TR-06-3) RTT Echo Responses inflated the measured
120 round-trip time by a constant factor. The sender will not retransmit
121 a packet again within one RTT of the previous attempt, so the inflated
122 value made it ignore the repeat NACKs needed when a retransmission is
123 itself lost, leaving packets unrecovered under sustained loss. The
124 Advanced echo now uses calculate_rtt_delay(), as the Simple and Main
125 profiles do.
126 - Fixed a receiver abort when a retransmitted or gap-filled packet's
127 arrival time is interpolated. With peers whose clocks are not
128 synchronised the estimate could fall outside its neighbouring queue
129 slots, tripping an assert in debug builds or misordering the queue
130 otherwise. Interpolation is now bounds-checked, rounded without
131 overshoot, wrap/reorder-aware, and clamped to the neighbour interval.
132 - NAT source-port rebind recovery (issue #188): when a calling
133 receiver's external source port changes (NAT mapping rebind, DHCP
134 renewal), the listening sender no longer treats it as a brand-new
135 caller that leaves the old peer record orphaned until session
136 timeout. Listener-side re-association requires an authenticated
137 per-peer SRP session: once a new child completes SRP authentication
138 and learns its cname from an RTCP SDES, its source tuple is migrated
139 into the matching silent sibling. This path is SRP-only because the
140 cname alone is not a per-peer secret under a shared PSK. Plaintext
141 and shared-PSK callers recover on the caller side instead: a
142 caller-mode receiver on a MAIN+ profile with no pinned local port
143 rebinds its UDP socket to a fresh ephemeral port on session timeout
144 and restarts the handshake instead of giving up.
145 - ?profile=0|1|2 in a peer URL (0=Simple, 1=Main, 2=Advanced) now
146 overrides the wire profile of the context that owns the peer.
147 rist_parse_address2 parses the value into rist_peer_config; on the
148 first matching peer added before rist_start(), rist_peer_create
149 mutates the context profile and lazily initialises the Advanced
150 profile state when upgrading to Advanced. Subsequent peers must
151 request the same profile (or omit the parameter); rist_peer_create
152 returns -1 with a WARN once the context profile is locked (after
153 rist_start() or a prior peer fixed it). Any consumer that passes
154 URLs through rist_parse_address2 + rist_peer_create now gets the
155 URL-driven profile selection with no further integration work.
156 - Fixed a use-after-free in the global logger when an application frees
157 its rist_logging_settings, either directly via
158 rist_logging_settings_free2() or by destroying a context that embeds
159 them (as FFmpeg does), while the global logger still references that
160 callback and argument. The global logging settings are now cleared
161 when the matching settings are freed, so logs emitted afterwards (for
162 example from background threads on a rapid close/reopen) no longer
163 call into freed memory.
164 - rist_peer_config_defaults_set() no longer writes past the end of a
165 peer config supplied by a binary compiled against an older
166 RIST_PEER_CONFIG_VERSION, and parse_url_options() / store_peer_settings()
167 no longer touch version-specific fields unless peer_config->version is
168 high enough: reflector, multicast_ttl, multicast_source and local_port
169 require version >= 2; srp_compat_legacy requires version >= 3.
170 - Windows XP support restored: rist_transport_poll() now uses
171 select() via the existing contrib/poll_win.c shim instead of
172 WSAPoll() (Vista+ only). Regression introduced in 0.2.17.
173 - rist_peer_recv() now accepts both canonical numeric EAGAIN errno
174 values (11 and 35) when a custom transport_ops backend signals
175 "no data ready", protecting cross-compile environments where the
176 EAGAIN macro can resolve differently across translation units.
177 - librist/transport.h now defines ssize_t on Windows (#214), so
178 downstream consumers no longer have to provide their own typedef.
179 - Prometheus exporter: counter rows in multiple_metric_datapoints
180 mode now have a space between the value and the timestamp.
181 Affected every existing _total row.
182 - Prometheus exporter: in single_stat_point mode, the displayed
183 value no longer freezes at the first callback and silently
184 drops every subsequent sample. Affected all receiver-flow,
185 sender-peer, and per-peer-receiver gauges.
186 - Receiver flow stats: bitrate, bitrate_retries, bitrate_rejected
187 and bitrate_ts_nulls now decay to zero when the corresponding
188 traffic stops, instead of remaining frozen at the last value
189 computed while traffic was still flowing (#217).
190
191 SRP interoperability:
192 - 0.2.16 made TLS-SRP RFC 5054 / TR-06-2 compliant by adding the
193 PAD operation to the u and k hash inputs. As a side effect,
194 SRP-authenticated peers running 0.2.15 or earlier (which omitted
195 the PAD) will not handshake with 0.2.16+. Upgrading both ends
196 to 0.2.16+ remains the recommended fix.
197 - New URL parameter for transitional interop:
198 ?srp-compat=1
199 On both ends of the SRP exchange, this opts the SRP wire format
200 back into the pre-0.2.16 unpadded form. Must be set on BOTH
201 sides; mixed configuration will still fail. An explicit WARN
202 is logged on startup when the option is active. Intended only
203 as an escape hatch while older deployments are upgraded.
204 - When an SRP handshake fails, the authenticator (and the client
205 on M2 mismatch) now emits a single INFO hint pointing at the
206 srp-compat=1 escape hatch. The hint is advisory only -
207 the SRP-6a transcript binds M1 to the authenticator's wire-mode
208 B, so there is no purely-local way to distinguish "wrong
209 password" from "peer is on the other wire format" once the
210 handshake has reached M1. No action required for non-SRP
211 deployments.
212
213 CI / Test Coverage:
214 - srp_unit_test now runs in test-ubuntu. cmocka is sourced via a
215 new subprojects/cmocka.wrap (WrapDB 1.1.8-1) so the test builds
216 even on runner images that do not ship libcmocka-dev, closing the
217 silent-skip gap that hid the SRP fixture drift reported in #215.
218 Test fixtures regenerated for the PAD-compliant SRP exchange
219 against the 2048-bit RFC 5054 group. Added four end-to-end tests
220 covering both PAD and legacy modes plus the two cross-mode failure
221 cases.
222 - The issue #188 NAT/socket-rebind and multipath cname integration
223 tests now compile under MSVC: they use the Windows pthread-shim
224 (runtime mutex initialisation and PTHREAD_START_FUNC thread entry
225 points) instead of a direct <pthread.h> dependency.
226
227 Tools:
228 - ristsender: new --blind-send option. Decouples the sender from
229 RIST peer state - multicast input groups are joined immediately
230 and incoming UDP data is written to the RIST context regardless
231 of whether any output peer has connected. Intended for
232 fire-and-forget broadcast topologies (multicast output in
233 simple/main/advanced profile, or ristsender used as a relay /
234 fan-out in front of non-RIST consumers).
235 - Prometheus exporter: new per-peer receiver metric block
236 rist_receiver_peer_* with labels {peer_id, peer_url, flow_id,
237 receiver_id}, mirroring rist_sender_peer_*. Auto-registered
238 from rist_stats_receiver_flow.peers[].
239 - Prometheus exporter: new client-flow gauge
240 rist_client_flow_avg_buffer_time_seconds reporting the dynamic
241 receiver buffer fill level (sourced from avg_buffer_time in
242 rist_stats_receiver_flow, converted from ms to seconds).
243 - Prometheus exporter: now also exports receiver counters that were
244 previously JSON-only: retries, dropped-late, dropped-full, duplicates,
245 and the NACK-depth recovery buckets (recovered after two / three / four
246 / more NACKs).
247
248
249 Changes for 0.2.17:
250 ---------------------------------
251
252 ABI/API:
253 - ABI version 12:0:8 (soversion 4, binary-compatible with 0.2.15)
254 - API version 4.9.0 (new features, backwards-compatible)
255 - RIST_STATS_VERSION bumped from 1 to 2 (new byte-counter fields
256 appended to rist_stats_sender_peer, rist_stats_receiver_peer,
257 and rist_stats_receiver_flow).
258 - RIST_STATS_JSON_SCHEMA_VERSION bumped from 2 to 3 (new fields:
259 sent_bytes, retransmitted_bytes, received_bytes).
260 - RIST_PEER_CONFIG_VERSION bumped from 1 to 2 (new fields:
261 multicast_ttl, multicast_source, local_port).
262
263 New Features:
264
265 Pluggable Transport Abstraction (transport.h):
266 - New rist_transport_ops vtable replaces direct socket syscalls with
267 user-supplied callbacks (sendto, recvfrom, socket, bind, close,
268 setsockopt, poll). Enables librist on non-POSIX platforms such as
269 WebAssembly/WebTransport, userspace network stacks, or unit-test
270 harnesses.
271 - New rist_transport_set() installs custom transport ops on a context.
272 - Default ops delegate to real syscalls so existing behaviour is
273 unchanged.
274
275 Packet Split / Merge (peer.h):
276 - Sender: split each application write into an even/odd sequence pair
277 when the payload exceeds half the path MTU. Controlled by
278 split_mode in rist_peer_config (off, auto, half).
279 - Receiver: transparently merge split pairs before delivery.
280 Controlled by merge_mode in rist_peer_config (off, pairs, auto).
281 - Keepalive advertises split capability via the L bit; receiver
282 auto-detects when the sender supports it.
283 - URL parameters: ?split=off|auto|half, ?merge=off|pairs|auto.
284 - Split/merge counters surfaced in JSON statistics.
285 - risttunnel auto-enables split+merge when MTU < 1400.
286
287 Advanced Profile (VSF TR-06-3):
288 - Wire format and protocol integration for the Advanced Profile as
289 defined by VSF TR-06-3.
290 - Native control plane: Keep-Alive with I bit (CI=0x8000), RTT Echo
291 Request/Response (CI=0x0010/0x0011), NACK Bitmask (CI=0x0000),
292 NACK Range (CI=0x0001), Unsupported Response (CI=0x8020).
293 - Full 32-bit sequence number indexing (expanded seq_index array).
294 - Type 8 GRE-over-AP encapsulation for Section 9 interoperability.
295 - PSK encryption mode 1 (AES-CTR, Main Profile compatible) with
296 per-packet Nonce/IV in the AP header.
297 - Future Nonce Announcement (CI=0x8011) for zero-latency key rotation.
298 - SRP (Secure Remote Password) passphrase exchange, reusing the EAP-SRP
299 state machine from Main Profile over Type 8 encapsulated EAPOL.
300 - Flow ID field (I flag): virt_dst_port and virt_src_port map to/from
301 the AP Outer/Inner Flow ID hierarchy on the wire.
302 - LZ4 payload compression (LPC=1): sender compresses before encryption,
303 receiver decompresses after decryption. Controlled by the existing
304 ?compression=1 URL parameter; receiver auto-detects via the LPC field.
305 Bundled LZ4 library in contrib/lz4/ with system-library fallback.
306 - Flow Attribute messages (CI=0x8001): sender periodically transmits
307 session/flow metadata as JSON. New receiver callback API
308 (rist_receiver_flow_attr_callback_set) delivers parsed attributes
309 to the application.
310 - Baseline.Direct conformance for single-flow encrypted point-to-point
311 RIST transport with ARQ.
312 - 22 integration tests (basic, packet loss, encryption, mismatch,
313 flow-id, lz4, lz4+encryption, flow-attr, SRP auth).
314 - 187 unit tests (wire format, timestamp, seq_index, Type 8, PSK modes,
315 Flow ID mapping, LZ4 roundtrip, flow-attr control roundtrip).
316
317 Per-byte statistics (#174):
318 - Sender stats now include sent_bytes and retransmitted_bytes counters
319 in both the C struct (rist_stats_sender_peer) and JSON output.
320 - Receiver flow stats now include received_bytes in the C struct
321 (rist_stats_receiver_flow) and JSON output.
322 - Per-peer receiver stats include received_bytes.
323
324 Multicast enhancements (#112):
325 - Configurable multicast TTL via ?ttl=N URL parameter (1-255).
326 New udpsocket_set_mcast_ttl() public API.
327 - IGMPv3 Source-Specific Multicast (SSM) support via ?source=IP
328 URL parameter. Uses IP_ADD_SOURCE_MEMBERSHIP / MCAST_JOIN_SOURCE_GROUP.
329 - IPv6 multicast join support (previously only IPv4 was implemented).
330 - New udpsocket_open_bind_mcast() with TTL and SSM source parameters.
331 - udpsocket_join_mcast_group() now public API, supports IPv6 and SSM.
332
333 Configurable local port for caller peers (#158):
334 - New ?local-port=N URL parameter to bind caller (non-listening) peers
335 to a specific local UDP port instead of using an ephemeral port.
336 - New local_port field in rist_peer_config.
337
338 Deferred multicast join in ristsender (#85):
339 - When ristsender's input URL is a multicast address, the IGMP join
340 is now deferred until the first RIST peer handshake completes.
341 Prevents receiving multicast traffic before the output path is ready.
342
343 WebAssembly / Emscripten:
344 - TUN device stubs for Emscripten targets.
345 - Meson cross-file (wasm32-emscripten.txt) for WASM builds.
346 - C99 strict-aliasing fix for merge memcpy.
347
348 Build:
349 - Bundled mbedTLS upgraded from 2.28.10 (EOL) to 3.6.6 LTS.
350 The bundled tree now compiles as a separate static library with
351 targeted warning suppression, isolating mbedTLS internals from
352 librist's strict compiler flags. Source compatibility fixes
353 applied for the 2.x -> 3.x API migration (removed _ret suffixes,
354 updated header paths). System mbedTLS 3.6.x is also fully
355 supported.
356 - Removed unused #include <mbedtls/entropy_poll.h> which broke
357 builds against system mbedTLS >= 3.6 where the header was removed.
358
359 Test:
360 - Loss simulation tests no longer abort on transient error log
361 messages. Under heavy bilateral loss, error-level messages are
362 expected and do not indicate bugs.
363 - Minimum receive threshold for loss tests now scales with the
364 configured loss percentage, giving headroom for ARQ recovery in
365 CI environments with timing jitter.
366
367 New features:
368 - Add transparent one-to-many reflector mode (Main Profile only).
369 A receiver listener configured with ?reflector=1 transparently
370 forwards data packets from the publisher (sender) to all subscriber
371 (receiver) peers, and routes NACKs/RTCP from subscribers back to
372 the publisher. Enables a single-listener fan-out topology without
373 requiring a full sender context on the reflector.
374 Trade-offs vs rist2rist (per-subscriber ARQ relay):
375 * No per-subscriber retry buffer — recovery relies on the
376 publisher's buffer, which may have aged out the packet.
377 * Retransmissions fan out to ALL subscribers, not just the one
378 that NACKed — bandwidth scales with subscriber count.
379 * Recovery RTT is roughly 2x a direct connection.
380 * No per-subscriber congestion control or statistics.
381 Best suited for low subscriber counts with clean last-mile links.
382 For high fan-out or lossy last-mile, use rist2rist instead.
383 (contributed by RossWang)
384
385 RTCP/NACK:
386 - Fix OOB read in NACK_FMT_SEQEXT handler: the RTCP feedback loop
387 validated only 4 bytes per record, but the seqext struct reads
388 seq_msb at offset 12. A crafted datagram with a short trailing
389 record could read up to 12 bytes past the allocation. Add a
390 per-handler minimum-length check matching the adjacent ECHO branches.
391 - Fix OOB read and log-disclosure in rist_sender_recv_nack: the NACK
392 range handler read the 4-byte name field at offset 8 with only an
393 8-byte minimum guarantee, and logged it with %s (unbounded read to
394 next NUL). Add a sizeof guard and use %.4s.
395
396 Log:
397 - Lower log level for harmless cross-role NACK/data packets from
398 ERROR/WARN to DEBUG to reduce log noise in reflector topologies.
399
400 EAP/SRP:
401 - Fix EAPOL-Start body length field: the packet declared a 4-byte body
402 (sizeof(eapol_hdr)) when the correct value is 0 (EAPOL-Start carries
403 no body). This bug was dormant until the bounds-check tightening in
404 0.2.15 started correctly rejecting oversized body declarations,
405 which broke every SRP handshake. SRP authentication has been
406 non-functional since 0.2.15.
407 - Fix off-by-one in eap_srp_send_password bounds check: the limit did
408 not account for the 1-byte flags field before the ciphertext, so a
409 maximum-length password would write 1 byte past the stack buffer.
410 Not network-reachable (all callers cap at 128 bytes), but worth
411 hardening.
412
413
414 Changes for 0.2.16 (pre-release):
415 ---------------------------------
416
417 ABI/API:
418 - ABI version 10:4:6 (soversion 4, binary-compatible with 0.2.15)
419 - API version 4.7.0 (unchanged)
420
421 Maintenance and security-hardening release for 0.2.15. No source or
422 binary changes are required of downstream consumers.
423
424 Bug Fixes:
425
426 Windows:
427 - Windows tools fail to start when remote logging is enabled.
428 Running `ristreceiver -r 127.0.0.1:port ...` on Windows 11 would
429 exit immediately with "Failed to setup logging!" because winsock
430 had not been initialised before the public logging API tried to
431 open a UDP socket. Fixes #208 (reported by Roman Dissertori).
432 - EAP-SRP authentication fails on Windows with multiple peers.
433 A 0.2.15 regression: an outbound packet that drew an ICMP
434 port-unreachable reply caused Windows to corrupt the next
435 incoming UDP datagram on the same socket, which then broke the
436 EAP handshake. Most visible with bonded ethernet+wifi peers,
437 Linux ristsender -> Windows ristreceiver. Fixes #209 (reported
438 and confirmed fixed by Roman Dissertori).
439 - Windows socket failure log lines now include the actual WSA
440 error code, so user bug reports from Windows are diagnosable.
441 - Cryptographic random number generator now seeds reliably on
442 Windows runtimes where the legacy CryptoAPI (CryptAcquireContext
443 / CryptGenRandom) is missing or unconfigured - notably wine and
444 some sandboxed container builds. The seeding path now uses the
445 modern BCryptGenRandom (CNG) API, supported on every shipping
446 Windows version. Without this fix, the 0.2.15 CSPRNG hardening
447 refused to start the SRP/AES code paths in those environments
448 rather than silently downgrade. Fixes #210.
449 - MSVC builds no longer crash due to stack corruption in atomic
450 operations. The stdatomic compatibility shim hardcoded all
451 operations to a single width, so a 64-bit compare-exchange on a
452 32-bit atomic variable overwrote adjacent stack memory.
453
454 Tools:
455 - ristsender now preserves incoming RTP sequence numbers and
456 timestamps when the --rtp-sequence and --rtp-timestamp options
457 are used. Previously these options had no effect.
458
459 Hardening / follow-ups to 0.2.15:
460
461 - EAP-SRP authentication retry exhaustion did not drop the failed
462 peer. A latent sign-comparison bug meant a peer that failed
463 every authentication retry was kept around in a half-
464 authenticated state instead of being dropped. Not externally
465 reported.
466 - Crypto random number generator could silently downgrade to a
467 weak fallback. If the CSPRNG seed call failed at startup (no
468 kernel entropy source - sandboxed container, embedded image
469 without /dev/urandom, broken build), the failure was dropped
470 and the wall-clock-derived stopgap was used for the lifetime of
471 the process. Now logs loudly and refuses to hand out random
472 bytes. Not externally reported.
473 - Internal EAP error code documentation: clarify a guard comment
474 that read as a removable paranoia check but is actually
475 protecting against a NULL function pointer.
476
477 Post-0.2.15 audit follow-ups (reported by Thomas Guillem):
478
479 Receiver flow / peer accounting:
480 - Receivers no longer crash or corrupt their peer list when a
481 peer is added to a flow at the same instant another thread is
482 removing one. The list of peers per flow was being walked by
483 one thread under one lock and modified by another thread under
484 a different lock; the two paths now agree. A 256-peer-per-flow
485 cap is also enforced so a misconfigured (or hostile) sender
486 cannot grow the list without bound.
487 - Receivers stop creating flows once 256 active flows already
488 exist. Previously the count was checked and the new flow
489 allocated in separate steps, so a burst of new flow IDs could
490 race past the limit. Now the count check and the slot insert
491 happen under the same lock.
492
493 EAP-SRP authenticator:
494 - Authenticated peers can no longer be deauthenticated by a
495 spoofed EAPOL-LOGOFF. A successfully authenticated session
496 used to reset to start-over state on receipt of any LOGOFF
497 packet, which made the auth state machine trivially DoSable
498 from off-path. LOGOFF is now only honoured before the session
499 reaches authenticated state, and a legitimate LOGOFF before
500 that point also resets the retry counter so a counter
501 wrap-around can't lock the peer out for the lifetime of the
502 process.
503 - A spoofed EAP FAILURE no longer pushes the local state machine
504 into permanent failure. FAILURE packets are now matched
505 against the identifier of the in-flight EAP exchange and
506 dropped if they don't match, the same way Request/Response are
507 matched. A genuine FAILURE still latches the peer out, but
508 after a 30-second quiet period the peer is allowed to retry
509 from the start so a transient burst of bad responses doesn't
510 require restarting the process.
511 - EAP authenticators no longer answer EAP Identity requests
512 themselves. The handler used to run on both roles, so a
513 misbehaving (or attacker-controlled) authenticatee could
514 persuade the authenticator to discard its own session state
515 and start over. The handler is now restricted to the
516 authenticatee role, and even there it is rate-limited so the
517 pre-auth reset cannot be triggered repeatedly to wipe
518 in-progress sessions.
519 - EAP SRP setup now caps the advertised modulus (N) and
520 generator (g) lengths at 1024 bytes (8192-bit groups, the
521 largest standard RFC 5054 group). A peer that advertised
522 multi-megabyte values used to allocate that much memory and
523 burn that much CPU on bignum imports before deciding the
524 handshake was bogus.
525
526 PSK encryption:
527 - The PSK nonce generator no longer falls back to a
528 wall-clock-derived value when the CSPRNG misbehaves. Nonces
529 are required to come from the system CSPRNG; if it fails or
530 returns suspect output the key is marked broken, encryption
531 refuses to produce ciphertext for that key (sends zeroes
532 instead so a downstream consumer cannot mistake it for a
533 successful encrypt), and the existing audible logging fires.
534 Decryption was already locked out in the same condition; this
535 closes the encrypt-side gap. The non-security-critical
536 `prand_u32` helper used elsewhere in the tree keeps its
537 wall-clock fallback because its callers don't need
538 unpredictability.
539 - PSK decryption now skips the PBKDF2 key derivation when the
540 key is already locked out. A bursty stream of malformed
541 encrypted packets at a peer whose key state was already
542 compromised used to spin tens of thousands of PBKDF2 rounds
543 per packet before rejecting it. The lockout check now happens
544 first, so the per-packet cost drops to a few comparisons.
545 - PSK AES-CTR dispatch no longer silently falls back to AES-128
546 on an unknown key size. The earlier switch-case used a
547 fallthrough that meant a corrupted or unsupported key length
548 would still be processed (with the wrong cipher), which
549 masked configuration errors. Unknown key sizes now return
550 without touching the buffer.
551
552 SRP / cryptographic primitives:
553 - The Nettle build of SRP no longer feeds uninitialized stack
554 into the bignum library when the CSPRNG returns no entropy.
555 The Nettle random callback's signature returns void, so a
556 CSPRNG failure was previously dropped on the floor and the
557 caller computed against whatever was on the stack. The
558 callback now zeroes its output buffer and signals the caller
559 via a side-channel context; the bignum operation then fails
560 cleanly. The mbedTLS build was already correct.
561 - The SRP NG (N/g) group identifier enum now keeps its
562 pre-0.2.15 integer values. The 0.2.15 release deleted the two
563 smallest groups (NG_512, NG_768 - both below current
564 minimum-strength thresholds) but shifted every remaining
565 enum entry down by two as a side effect. The integer "2",
566 which any external caller might reasonably have hardcoded
567 for NG_1024, silently started meaning NG_4096. The deleted
568 values 0 and 1 are now explicit reserved slots that return
569 "no such group" - code that uses the named constants
570 (`LIBRIST_SRP_NG_1024` etc.) is unaffected, code that used
571 literal integers either gets the group it asked for or a
572 clean error.
573
574 Statistics JSON:
575 - The stats JSON payloads (sender flow, sender per-peer wrapper,
576 receiver flow) now carry an explicit top-level
577 `schema_version` field. The current value is 2 - version 1 was
578 the duplicate-`peer`-key sender shape that v0.2.15 replaced
579 with a `peers` array (NEWS noted the change, but downstream
580 parsers had no way to detect which shape they were getting).
581 Any future incompatible shape change must bump this number.
582 - The sender `cname` field copy is now explicitly
583 NUL-terminated. The previous strncpy with a destination-sized
584 length depended on a separate bounds check elsewhere in the
585 receive path to keep the result safe; the contract is now
586 self-contained.
587
588 Build / portability:
589 - librist now requires mbedTLS >= 2.7 (March 2018), and emits a
590 clean #error if built against anything older. The compatibility
591 branch for pre-2.7 mbedTLS releases (which used the
592 void-returning SHA-256 API) had no CI coverage and was the
593 same untestable corner that produced a 0.2.14 build break -
594 dropping it removes the surface area entirely. Every still-
595 supported distro is well past 2.7; the bundled tree is 2.28.x.
596 - On Windows, the mbedTLS CSPRNG seed no longer reaches into
597 private mbedtls_entropy_context fields to keep its source
598 count happy. It now seeds the CTR_DRBG directly from
599 BCryptGenRandom, skipping the entropy module entirely on
600 Windows. Non-Windows builds still use the normal entropy
601 initialisation path.
602
603 Second audit follow-ups (reported by Thomas Guillem):
604
605 EAP-SRP authentication:
606 - EAP passphrase response handler now gates on a matching
607 outstanding request identifier when a solicited passphrase
608 exchange is active. Previously any post-auth spoofed
609 RESPONSE/PASSWORD_REQUEST_RESPONSE was accepted, allowing a
610 man-on-the-side to hijack a key-rotation exchange. Unsolicited
611 passphrase pushes (rist_eap_send_passphrase) remain allowed as
612 the payload is encrypted under the SRP session key.
613 - EAP last_identifier is no longer primed in the request prologue
614 before subtype validation. A spoofed REQUEST with a crafted
615 identifier could prime the FAILURE-identifier gate, allowing a
616 subsequent spoofed FAILURE to latch the peer out.
617 - EAP authenticator initial identifier now comes from the CSPRNG
618 instead of prand_u32, closing an off-path prediction window.
619 - The use_default_2048 flag in EAP SRP challenge processing was
620 hardcoded true, ignoring wire-supplied N/g groups. Now derived
621 from the actual generator length on the wire.
622 - eap_set_ip_string replaced an unbounded memcpy with strncpy and
623 explicit NUL-termination.
624
625 EAP-SRP / cryptographic primitives:
626 - SRP u and k hash computations now use RFC 5054 PAD: both inputs
627 are zero-extended to the byte length of N before hashing. The
628 previous unpadded hash produced different values for leading-
629 zero-byte operands, deviating from the specification. This is a
630 wire-incompatible change with pre-0.2.16 peers using SRP.
631 - SRP M1/M2 verification and client M2 verification now use a
632 constant-time comparison instead of memcmp.
633 - SRP authenticator aborts if the verifier v is zero (session key
634 would not depend on the password).
635 - SRP authenticator aborts if B mod N == 0 (RFC 5054).
636 - SRP authenticator aborts if u == 0 mod N after hashing A||B.
637 - SRP hash return values are now checked; unchecked failures
638 previously left uninitialised buffers in the session transcript.
639 - SRP BIGNUM_EXP_MOD return after computing S is now checked.
640 - SRP client context creation now validates modulus length
641 [128, 1024], generator length [1, N_len], and salt length
642 [1, 64] to cap resource consumption from malformed handshakes.
643 - SRP private exponent size now matches the modulus size instead
644 of a hardcoded 32 bytes, providing full-strength keying for
645 large groups (e.g. NG_8192).
646 - SRP salt generation now uses fixed-size 32-byte raw CSPRNG
647 output copied directly, instead of going through bignum export
648 which strips leading zero bytes and shrinks the effective salt
649 domain.
650
651 Receive path / flow safety:
652 - Use-after-free on flow deletion during rist_receiver_data_read2
653 is fixed. The flow pointer returned by the lookup function is
654 now validated under flows_lock; the flow's own mutex is acquired
655 before flows_lock is released. rist_delete_flow unlinks the
656 flow under the same lock before freeing.
657 - rist_receiver_set_output_fifo_size now rejects size == 0 and
658 size > 65536, preventing a zero-modulus OOB on the FIFO ring.
659 - rist_peer_get_cname uses strnlen instead of strlen, bounded by
660 RIST_MAX_STRING_SHORT.
661
662 MPEG-TS null packet handling:
663 - expand_null_packets now bounds-checks each source-packet copy
664 against the original payload length, preventing an information
665 leak of adjacent buffer data when the NPD bit pattern implies
666 more real packets than the payload actually contains.
667 - suppress_null_packets now checks the sync byte of every packet
668 in the block, not just the first.
669
670 SDES / cname / miface:
671 - RTCP SDES writer uses strnlen instead of strlen and zero-fills
672 the padding region explicitly, instead of copying adjacent
673 memory from the source buffer.
674 - All strncpy sites for peer cname and miface (peer_initialize,
675 rist_peer_clone) now have explicit NUL-termination.
676
677 PSK encryption:
678 - PSK key init now uses strnlen and explicit NUL-termination
679 instead of unbounded strlen + memcpy.
680 - PSK key clone now explicitly NUL-terminates the copied password.
681 - PSK decrypt no longer unconditionally clears bad_decryption
682 after rekeying; if _librist_crypto_aes_key set the flag (PBKDF2
683 failure), it stays set so the lockout counter is not reset.
684
685 Sender:
686 - sender_buffer_size growth is now capped at sender_queue_max - 1,
687 preventing unbounded memory growth when packets are too young to
688 delete from the retry queue.
689 - rist_sender_peer_create now calls rist_peer_remove instead of
690 bare free on RTCP-peer creation failure, preventing a dangling
691 pointer in the peer list.
692
693 Miscellaneous:
694 - rist_peer_remove dead store fixed: *next = NULL now executes
695 before the early return on NULL peer.
696 - NACK debug log guarded against zero-length array dereference
697 and uses %zu for size_t.
698 - is_ip_address uses a union of in_addr/in6_addr for the
699 inet_pton destination buffer, fixing an AF_INET6 stack overflow
700 that wrote 16 bytes into a 4-byte sockaddr_in.sin_addr.
701 - rist_new_connection log format strings replaced char[] locals
702 passed via &array with const char * pointers, eliminating
703 strict-aliasing undefined behaviour in the varargs call.
704 - rist_tun_write overflow guard changed from
705 len + UTUN_HEADER_SIZE > sizeof(tmp) to
706 len > sizeof(tmp) - UTUN_HEADER_SIZE, preventing unsigned
707 wraparound when len is near SIZE_MAX.
708
709 Community bug reports (gitlab #211, RossWang):
710
711 Receiver flow timing:
712 - Initialize last_packet_ts, time_offset_changed_ts, and
713 time_offset_old when a flow (re)starts. After a flow reset the
714 stale values from the previous epoch could cause the old-clock
715 fallback to fire, corrupting packet timing and dropping the
716 first few packets.
717
718 OOB dequeue:
719 - rist_oob_dequeue now holds peerlist_lock while walking a
720 listener peer's child list. A concurrent peer add/remove could
721 free a sibling_next pointer during the walk.
722
723 Note: _librist_peer_match_peer_addr (#211 item 3) also walks the
724 child list without a lock, but cannot use peerlist_lock because the
725 receive callback runs on the same thread that holds it in the
726 protocol loop. Fixing this requires a per-listener child rwlock or
727 reference counting, planned for a future release.
728
729 Test / CI:
730 - New unit test (logging_init_order) that exercises the
731 rist_logging_set remote-address path before any rist_*_create
732 call. Would have caught #208 on the first Windows-CI run.
733 - The full meson test suite now runs against the cross-compiled
734 Windows binaries under wine, not just on Linux. Every protocol
735 test that gates Linux releases also gates Windows releases,
736 including the SRP / AES encryption suites which are now built
737 with mbedTLS on Windows (see the #210 fix above). The wine
738 runtime was already provisioned in the CI image; only the test
739 invocation was missing. Catches Windows-runtime regressions
740 without requiring a native Windows runner.
741 - Per-test results from the Linux job now show up directly in the
742 GitLab MR UI via meson's JUnit output, so reviewers don't have
743 to read job logs to see which test failed.
744
745
746 Changes for 0.2.15 (2026-05-14):
747 --------------------------------
748
749 ABI/API:
750 - ABI version 10:3:6 (soversion 4, binary-compatible with 0.2.14)
751 - API version 4.7.0 (unchanged)
752
753 Security release. Existing 0.2.14 installations remain
754 binary-compatible; downstream consumers do not need to recompile.
755
756 Security Fixes:
757
758 Receive-side parsers and key handling were audited end to end. Each
759 fix below is independent.
760
761 Receive path / RTCP:
762 - rist-common: bounds-check the RTP and RTP-extension headers.
763 The earlier check only covered the 4-byte reduced port subheader;
764 a truncated packet underflowed payload.size to ~SIZE_MAX which
765 then drove a malloc(len + 32) on the receiver enqueue path.
766 - rist-common: harden the RTCP dispatcher. Off-by-one in
767 bytes_left, integer overflow in 4*(1+records) (CPU spin on a
768 single packet), and an SDES handler that let 255 bytes be
769 memcpy'd into a 128-byte struct member, overrunning the adjacent
770 peer config/key state.
771 - rist-common: bound the XR block parser, clamp the on-the-wire
772 length to what we received, and guard the DLRR delay subtraction
773 so it can no longer pin last_rtt near UINT64_MAX (which would
774 permanently disable NACK timing on the peer).
775 - rist-common: validate the sender NACK record count before
776 iterating. ntohs(rtcp->len) - 2 underflowed to ~65K on a
777 malformed feedback packet, enqueueing OOB bytes as retransmit
778 requests and leaking them back to the peer.
779 - rist-common: add the missing return after the VSF length check,
780 and derive odd_nonce from the actual nonce byte rather than
781 GRE flags1 (the latter silently disabled the OTF passphrase
782 rotation feature on the receive side).
783 - rtcp: guard the RR and echo-response RTT subtractions and
784 size-check the SR / echo-request / echo-response casts (same
785 RTT-underflow primitive as above on the RR/echo paths).
786 - rtcp: correct the XR echoreq RTCP length field per RFC 3550;
787 receivers were reading 4 bytes past the actual XR block.
788 - mpegts: bound NPD expansion to the 7-packet wire encoding.
789 expand_null_packets used attacker-controlled payload_len and
790 npd_bits to drive ts_count and write up to 11 KB into a 10 KB
791 recv_npd buffer (overrunning into the adjacent RTCP TX buffer),
792 and shifted by a negative amount when ts_count > 7.
793 - gre: zero-init keepalive info on short packet and check return,
794 otherwise a truncated keepalive disclosed stack memory through
795 the user logging callback.
796 - udpsocket: NUL-terminate the URL hostname after strncpy so
797 udpsocket_resolve_host cannot over-read.
798
799 PSK / AES-CTR:
800 - crypto: reject zero-nonce PSK packets instead of skipping
801 decryption. The previous early-return left the recv buffer
802 untouched and the caller treated the attacker's plaintext as a
803 freshly-decrypted Main Profile packet, bypassing the configured
804 PSK per packet. Pre-auth, single packet.
805 - crypto: correct nettle AES-CTR dispatch for 128/192-bit keys.
806 AES-128 was using nettle_aes192_encrypt against an aes128
807 context; the AES-192 case was missing entirely, leaving an
808 uninitialised function pointer hot on the EAP password-rotation
809 path.
810
811 EAP / SRP:
812 - eap: validate EAPOL/EAP/SRP-TLV lengths end to end. The body
813 length check was inverted and inner dispatchers walked past the
814 recv buffer with attacker-supplied lengths, exfiltrating heap
815 bytes through username copies and AES-CTR rewrites. Adjacent
816 fixes cover EAP header / dispatch / passphrase-flags reads.
817 - eap: NULL-check auth_ctx and propagate handle_A failure (notably
818 A == 0 mod N) so a rejected SRP exchange actually fails auth
819 instead of sending an uninitialised B back to the client. NULL
820 check the SRP client ctx and propagate the int-typed return of
821 the A/B writers (a -1 wrapped to ~SIZE_MAX and crashed on the
822 last_pkt malloc cache path).
823 - eap: bound rist_eap_send_passphrase to the destination buffer;
824 an over-long passphrase from the API or YAML config overran
825 ctx->unsollicited_passphrase into adjacent heap fields used by
826 the periodic retransmit.
827 - eap: rate-limit the EAP_CODE_FAILURE restart loop. The handler
828 unconditionally called eap_reset_data + log + EAPOL_START with
829 no retry counting, so a spoofed FAILURE per round-trip kept us
830 bouncing through reset+restart forever.
831 - eap: write the empty server-name placeholder into outpkt rather
832 than pkt (pure copy/paste typo that corrupted the recv buffer
833 on every successful identity response).
834 - srp: propagate failure when the client A, server B, or u is
835 congruent to 0 mod N. The checks existed but the failure path
836 left ret==0 so the caller continued the exchange. Auth bypass
837 primitive on both sides.
838
839 PRNG:
840 - crypto: route prand_u32 through the CSPRNG. The previous
841 implementation called rand() seeded with a wall-clock NTP
842 timestamp; the result is used for the PSK GRE nonce (input to
843 PBKDF2), the EAP identifier and the peer SSRC. Reuse the mbedTLS
844 CTR-DRBG / GnuTLS RNG that already backs SRP key generation.
845 - crypto: fix operator-precedence bug in random_get_string and
846 add an upper bound on the local rand buffer. Affected callers
847 that ask for a runtime-derived password.
848
849 Hygiene (not security-impacting on their own but shipped in the same
850 release):
851 - flow: handle realloc/calloc failure on the peer-list growth path
852 and rist_receiver_missing; correct two log format strings
853 (uint32_t printed with PRIu64; pointer where a PRIu32 was due).
854 - libevsocket: preserve the global context list when removing the
855 head; ctx_del previously cleared CTX_LIST instead of advancing
856 it to c->next.
857 - eap, logging, udpsocket: NULL-check the malloc/calloc results
858 that were dereferenced unconditionally; free the calloc'd ctx
859 on pthread_mutex_init failure in eap_clone_ctx; close the bound
860 socket on the multicast-join failure leg.
861 - network: on the GNU/Hurd MAC-address path, check socket() and
862 close it on the getifaddrs() failure leg.
863
864 Additional fixes from the VideoLAN security audit:
865
866 Independent receive-side / EAP / SRP audit shared by VideoLAN.
867 The findings already covered above are not re-listed; the items
868 below close the residual gaps.
869
870 EAP / SRP:
871 - eap: ignore EAP_REQUEST_IDENTITY once we're past
872 EAP_AUTH_STATE_SUCCESS so a single forged identity request can
873 no longer tear an established session down and re-emit the
874 configured username on the wire.
875 - eap: refuse RESPONSE/IDENTITY on the authenticatee side
876 (lookup_func is NULL there per the calloc setup path; the
877 handler used to deref it unconditionally).
878 - eap: free verifier_data on every exit from
879 process_eap_response_identity. Three error paths returned -1
880 before reaching the cleanup block, leaking the four heap
881 allocations the verifier lookup callback handed back.
882 - srp: jump to failed: instead of returning out of
883 BIGNUM_WRITE_BYTES when MPI write fails inside calc_x; the
884 return -1 path leaked hash_data.
885 - srp: check librist_crypto_srp_hash_bignum return in
886 calculate_m. The helper returns -1 (and leaves the output
887 buffer untouched) when the bignum exceeds its 1024-byte
888 staging buffer; the unchecked path XOR'd uninitialised stack
889 into the SRP transcript.
890 - srp: BIGNUM_INIT k and B in the authenticator constructor.
891 Relying on calloc-zeroed mbedtls_mpi state happened to work
892 today but the public mbedTLS contract requires explicit init.
893 - srp: bound A and B operand sizes against N before exp_mod.
894 handle_A and client_handle_B accepted any length from the
895 wire; mbedtls_mpi_exp_mod runtime grows with operand size.
896 - srp: NULL the caller's *bytes_s/*bytes_v in _create_verifier
897 failure paths so eap_reset_data does not double-free them.
898 - srp: capture mbedtls_mpi_fill_random return when generating
899 the salt; the previous `if (ret != 0)` re-checked the prior
900 BIGNUM_FROM_STRING.
901 - srp: repair the !USE_SHA_RET branch of librist_crypto_srp_hash
902 (referenced symbols from a different function and was missing
903 its trailing semicolon).
904 - srp: drop the sub-1024-bit RFC 5054 groups (NG_512, NG_768).
905 The enum was internal; the unit-test fixture that wanted the
906 deterministic 512-bit exchange now inlines the constants.
907
908 PSK / AES-CTR:
909 - psk: fail closed when PBKDF2 setup fails on the mbedTLS path.
910 mbedtls_md_setup / mbedtls_pkcs5_pbkdf2_hmac errors used to
911 fall through into mbedtls_aes_setkey_enc with the
912 stack-allocated aes_key buffer in undefined state.
913 - psk: don't let an attacker-chosen nonce reset the bad-packet
914 lockout. _librist_crypto_psk_decrypt now keeps bad_decryption
915 set across nonce rolls so the five-bad-packets cap is no
916 longer trivially bypassed by sending a different nonce on
917 every shot.
918 - psk: use memcpy for the GRE nonce load instead of a punned
919 uint32_t cast (strict-aliasing UB; faulted on architectures
920 that require aligned uint32_t loads).
921
922 Receive path:
923 - rist-common: lift the rist_rtp_hdr size check above the
924 Simple/REDUCED conditional so Main-profile FULL/EAPOL paths
925 can no longer read past recv_bufsize.
926 - udp: size the NPD scratch buffer for the real worst case
927 (7 * 204 + sizeof(rist_rtp_hdr_ext)). The previous 6 * 204 + 4
928 was four bytes short for the (count == 7, suppressed == 1)
929 output and let suppress_null_packets smash four bytes of
930 stack past tmp_buf.
931 - rist-common: cast keepalive json_len to int for %.*s. size_t
932 via varargs is undefined per the C standard.
933
934 Flow / threading:
935 - flow: take f->mutex when growing peer_lst; the realloc could
936 move storage and concurrent walkers (rist_best_rtt_index, the
937 output thread, stats) read peer_lst without synchronization.
938 - flow: cap receiver flows at RIST_MAX_FLOWS (256) and walk
939 FLOWS under flows_lock. Without a cap an attacker that can
940 land traffic on a receiver can exhaust memory by walking the
941 32-bit flow_id space.
942 - flow: NULL-check the dataout_fifo_queue calloc; the
943 data-output thread used to write into it unconditionally.
944
945 TUN / RTCP TX / utility:
946 - tun_linux, tun_darwin: bounds-check prefix_len before computing
947 the netmask. prefix_len < 0 hit undefined behaviour in C and
948 prefix_len == 32 produced a 32-bit shift on a uint32_t (also
949 UB).
950 - tun_darwin: parse the utun unit suffix with strtoul, not atoi,
951 with full validation; falls back to "let the kernel pick" on
952 parse failure.
953 - rtp: clamp SDES name_len to 255 before computing sdes_size so
954 the on-the-wire length byte and the actual bytes copied stay
955 in agreement.
956 - rist-common: make compare() return a real three-way result
957 (qsort's contract is < 0 / 0 / > 0; the previous boolean cast
958 was undefined per POSIX).
959 - rist-common: pick the actual median in recalculate_clock_offset
960 (the index was biased high by one).
961
962 Bug Fixes:
963 - rist-common: initialize peer->sd to -1 in peer_initialize so a
964 DNS resolution failure no longer leaves a zero socket
965 descriptor wired up to the event loop, which on Windows turned
966 into an infinite POLLERR loop and on Unix could attach the RIST
967 state to fd 0 (stdin). (!312, Yannick Le Roux)
968 - logging: check log_socket >= 0 instead of just non-zero in the
969 rist_log_impl UDP path, matching the LOGGING_SETTINGS_INITIALIZER
970 sentinel (the early-exit was tightened in f7ace4d but the send
971 branch still treated 0 as a valid fd). (!313, Daisuke Matsunami)
972 - stats: emit sender peers under a "peers" array. The previous
973 shape used "peer" as the key for every peer object, producing
974 invalid JSON and silently dropping all but one peer in strict
975 parsers. (#206, Manuel Alejandro)
976
977 Tools:
978 - prometheus-exporter: implement rist_prometheus_parse_sender_stats.
979 The hook for ristsender's JSON stats callback was a TODO stub, so
980 sender-side rist_sender_peer_* gauges/counters never showed up at
981 the scrape endpoint. The parser now walks the new "peers" array
982 and feeds rist_prometheus_handle_sender_peer_stats; metric names
983 and shape are unchanged from the receiver-callback path.
984 (closes the second half of #206)
985 - ristsender: drop a duplicate rist_sender_stats_callback_set call
986 in setup_rist_peer that overwrote the per-instance arg with NULL,
987 breaking sender attribution when more than one sender ran in the
988 same process.
989 - udp2udp: log a one-shot warning when --metrics is enabled noting
990 that the relay produces no rist_* series (it uses librist only
991 for URL parsing and the httpd shell).
992
993 Windows / MinGW Build:
994 - rist.c: return integer (not NULL) from the PTHREAD_START_FUNC
995 bodies. The macro expands to a DWORD __stdcall function on
996 Windows without HAVE_PTHREADS, which gcc14 rejected.
997 - meson: always probe clock_gettime via has_header_symbol on
998 Windows, not only when have_mingw_pthreads=true. Modern
999 mingw-w64 ships clock_gettime as a static inline in <time.h>
1000 regardless of winpthreads, so contrib/time-shim.c collided
1001 with the toolchain definition on the default build.
1002 - rist-common: drain WSAECONNRESET with a real recvfrom buffer
1003 on the rist_peer_sockerr POLLERR path. The previous NULL-buffer
1004 call returned WSAEFAULT and left the indication in the socket
1005 queue, causing WSAPoll to fire POLLERR in a tight loop and
1006 flood the log with "Socket error!" whenever a peer went away.
1007 (#205, Manuel Alejandro)
1008 - tools: centralize the strtok_r/strtok_s shim in a header so
1009 rist2rist (and any future tool that needs strtok_r) builds on
1010 MinGW / MSVC. ristsender and ristreceiver had inline shims;
1011 rist2rist's recent multi-peer bonding work added strtok_r
1012 without one and failed to link. (#207, Thierry Lelegard)
1013
1014 Changes for 0.2.14 (2026-04-25):
1015 --------------------------------
1016
1017 ABI/API:
1018 - ABI version 10:2:6 (soversion 4, binary-compatible with 0.2.13)
1019 - API version 4.7.0 (unchanged)
1020
1021 Maintenance release. No public API or ABI signature changes.
1022 Existing 0.2.13 installations remain binary-compatible; downstream
1023 consumers do not need to recompile and relink.
1024
1025 Bug Fixes:
1026
1027 - fix(sender): serialize retry-queue dequeue under peerlist_lock
1028 to avoid a use-after-free. The retry-queue cleanup path could
1029 race with peer teardown and dereference a peer that had already
1030 been freed on a sibling thread, occasionally producing a sender
1031 crash under sustained NACK pressure with multi-peer
1032 configurations. The dequeue is now performed with the peerlist
1033 lock held for the full critical section.
1034 - fix(macos): honor the -1/errno contract in the time-shim and
1035 zero-initialize the timespec before calling clock_gettime_osx.
1036 rist__get_system_boottime() previously returned the errno value
1037 as its result instead of -1, which silently produced corrupted
1038 NTP timestamps on macOS in restricted-syscall environments
1039 (containers, sandboxes that block sysctl(KERN_BOOTTIME)). The
1040 function now returns sysctl()'s actual return value, and
1041 timestampNTP_u64() / timestampNTP_RTC_u64() defensively
1042 zero-init their timespec so a clock_gettime failure can no
1043 longer leak uninitialized stack into the time arithmetic and
1044 falsely trip the "stream is dead" timeout.
1045
1046 Windows / MSVC / MinGW:
1047
1048 - contrib/poll_win: fix the Windows poll() emulation busy-spinning
1049 at 100% CPU when the watched fd set contains only sockets
1050 (the common case for librist). The previous implementation fell
1051 through to a 0 ms select() loop whenever no pipe/handle fds were
1052 present; the timeout argument is now correctly honoured in the
1053 sockets-only path.
1054 - msvc: round out the contrib stdatomic shim and select native
1055 C11 atomics where the toolchain supports them. Restores
1056 correct atomic_uint_fast64_t behaviour on MSVC builds where
1057 earlier shim coverage left some operations as plain reads /
1058 writes, which (under heavy contention) could let the receiver
1059 flow's last_pkt_received drift and produce false stream-dead
1060 events on Windows.
1061
1062 Tools:
1063
1064 - tools/rist2rist: add multi-peer bonding (multiple input or
1065 output URLs on the command line), MPEG-TS Null Packet Deletion
1066 (NPD), and Prometheus metrics export. rist2rist can now serve
1067 as a load-balancing relay sitting close to the source of truth,
1068 where small recovery buffers and large retry queues let
1069 downstream receivers absorb network impairments without
1070 inflating end-to-end latency.
1071
1072 Contrib (bundled mbedtls):
1073
1074 - contrib/mbedtls: refresh bundled source from 2.26.0 to 2.28.10
1075 (last LTS release of the 2.x series, 2025-03-24). 2.28.x is
1076 strictly ABI-compatible with 2.26.x, so no librist code change
1077 was required. Notable mbedtls fixes pulled in:
1078 * CVE-2025-27809 (TLS server impersonation via missing
1079 mbedtls_ssl_set_hostname)
1080 * CVE-2025-27810 (TLS 1.2 Finished message corruption on
1081 allocator/HW failure)
1082 * CVE-2024-45157 (PSA HMAC_DRBG selection regression)
1083 * Multi-year accumulation of fixes in AES, ECP, MPI, RSA,
1084 PK, PKCS5, bignum and the new constant_time.c
1085 side-channel-hardened primitives.
1086 librist itself only consumes the classic mbedtls crypto API
1087 (AES-CTR, CTR-DRBG, entropy, SHA-256, PBKDF2, MPI), so the
1088 upgrade is a drop-in replacement for the bundled path. The
1089 system-mbedtls build path (-Dbuiltin_mbedtls=false, the
1090 default when a system libmbedcrypto is detected) is not
1091 touched by this commit.
1092 - contrib/mbedtls: widen the hardclock gate from defined(_MSC_VER)
1093 to defined(_WIN32) in the bundled timing.c, so MinGW and
1094 Clang-Windows builds now also pick up the
1095 QueryPerformanceCounter implementation of
1096 mbedtls_timing_hardclock().
1097
1098 Contributors:
1099 - Sergio Ammirata
1100
1101
1102 Changes for 0.2.13 (2026-04-18):
1103 --------------------------------
1104
1105 ABI/API:
1106 - ABI version 10:1:6 (soversion 4, binary-compatible with 0.2.12)
1107 - API version 4.7.0 (unchanged)
1108
1109 Build Fixes:
1110
1111 Platform build-fix release. No changes to the RIST protocol, public
1112 API, or ABI signatures. All existing 0.2.12 installations remain
1113 binary-compatible; downstream consumers do not need to recompile.
1114
1115 This release is only relevant if you build librist targeting one of
1116 the platforms listed below. Native Linux, native macOS, FreeBSD,
1117 and classic Win32 builds with MSVC are unaffected.
1118
1119 Windows desktop built with mingw-w64 (gcc or llvm-mingw):
1120 - meson: detect clock_gettime with has_header_symbol
1121 v0.2.12's probe used cc.has_function('clock_gettime'), which
1122 does not resolve the static inline definition shipped by
1123 mingw-w64's <pthread_time.h>. The resulting HAVE_CLOCK_GETTIME=0
1124 caused contrib/time-shim.h to emit a conflicting extern
1125 declaration and broke any downstream build with strict warnings
1126 ("redefinition of 'clock_gettime'"). Switching to
1127 cc.has_header_symbol detects the inline correctly.
1128
1129 Windows UWP (i686/x86_64/aarch64-w64-mingw32 UWP toolchains):
1130 - Also fixed by the has_header_symbol probe above.
1131 - network.c: replace GetAdaptersInfo with GetAdaptersAddresses
1132 _librist_network_get_macaddr() called GetAdaptersInfo, which is
1133 not part of the UWP (WINAPI_FAMILY_APP) API surface;
1134 llvm-mingw's UWP iphlpapi import library does not export it,
1135 so UWP consumers of librist.a failed to link with "undefined
1136 symbol: _GetAdaptersInfo". Replaced with GetAdaptersAddresses,
1137 supported on classic Win32 desktop and on UWP since Windows 8.
1138
1139 Embedded Apple SDKs (iOS, tvOS, watchOS, visionOS, all archs):
1140 - tun_darwin.c: build as stubs on non-macOS Apple platforms
1141 The v0.2.12 TUN support was guarded by #ifdef __APPLE__, but
1142 <sys/kern_control.h> and <net/if_utun.h> only ship with the
1143 macOS SDK. Every non-macOS Apple cross-build failed with
1144 "fatal error: 'sys/kern_control.h' file not found", and simply
1145 gating off the file produced a later link error because
1146 src/rist.c and src/rist-common.c call rist_tun_read /
1147 rist_tun_write unconditionally. Pull in <TargetConditionals.h>,
1148 restrict the utun implementation to
1149 defined(__APPLE__) && TARGET_OS_OSX, and add a second
1150 #elif defined(__APPLE__) branch with stub implementations of
1151 the seven public rist_tun_* entry points returning -1, matching
1152 the pattern src/tun_win.c already uses on Windows. Real utun
1153 support on macOS is unchanged.
1154
1155 macOS used as a cross-build HOST:
1156 - meson: skip Homebrew prefix lookup for cross-builds
1157 The Homebrew fallback that adds /opt/homebrew or /usr/local
1158 include paths was running unconditionally on any Darwin host.
1159 Macs cross-compiling librist for iOS, tvOS, visionOS, Android,
1160 or mingw could hang or fail at configure. Gated the lookup on
1161 a native macOS build. Native-macOS-for-macOS builds are
1162 unaffected.
1163
1164 Contributors:
1165 - Sergio Ammirata
1166
1167 No source-file changes outside of meson.build, src/network.c, and
1168 src/tun_darwin.c.
1169
1170
1171 Changes for 0.2.12 (2026-04-17):
1172 --------------------------------
1173
1174 ABI/API:
1175 - ABI version 10:0:6 (soversion 4, binary-compatible with 0.2.11)
1176 - API version 4.7.0
1177
1178 New Features:
1179 - Cross-platform TUN support moved into the library
1180 (rist_tun_open/close/read/write/set_ip/set_mtu/bring_up)
1181 macOS (utun), Linux (/dev/net/tun), Windows (stub)
1182 - data_fd forwarding API: rist_sender_data_fd_set,
1183 rist_receiver_data_fd_set, rist_data_fd_stats_get
1184 librist reads/writes directly to the fd, no application
1185 code in the data path (works with sockets, FIFOs, TUN fds)
1186 - New risttunnel tool: point-to-point IP tunnel over RIST
1187 - YAML config file support for ristsender/ristreceiver with native parser
1188 - Receiver session timeout API and --session-timeout CLI option
1189 - Peer statistics in receiver output
1190 - Multicast interface (miface) in sender peer statistics JSON
1191 - avg_buffer_time field exposed in receiver_flow stats struct
1192 - New udp2udp tool for UDP relay
1193 - Profile selection (--profile) in rist2rist
1194 - Sender input queue statistics
1195 - MPEG-TS null packet suppression byte tracking
1196 - Differentiated bitrate tracking and sender stats API
1197
1198 Bug Fixes:
1199 - Fix sender queue full detection: replace wrap-unsafe index
1200 arithmetic (which silently misfired on ring-buffer wraparound)
1201 with a size-vs-max comparison. Prevents in-flight retransmit
1202 buffers from being silently overwritten under sustained load.
1203 - Fix OOB main-profile data delivery: rist_send_seq_rtcp no
1204 longer strips the first 4 bytes of zero-header OOB packets,
1205 and rist_oob_dequeue now iterates child peers when the OOB
1206 buffer references a listener peer (matching main-channel
1207 behaviour instead of failing silently).
1208 - Fix receiver crash on configurable RTT multiplier path
1209 - Fix bogus lost-packet counters
1210 - Fix premature stream stop on ECHO timeout for single-path (closes #196)
1211 - Fix multi-sender queue issues (static buffer_size moved to context)
1212 - Thread-safe FIFO access in rist_receiver_data_read2
1213 - Fix memory leaks (authentication failures, sender queue)
1214 - Fix OpenMetrics response: add missing trailing EOF line
1215 - Fix rist_client_flow_quality metric unit
1216 - Fix OpenMetrics Content-Type header for Prometheus compatibility
1217 - Fix RTT min/max invalid values
1218 - Fix const correctness in URL parameter parsing
1219 - Fix signed/unsigned comparison statements
1220 - Fix missing strings.h include in yamlparse.c
1221 - Fix clock used when processing RR with lsr older than last SR
1222 - Fix -Wmisleading-indentation warning in receiver FIFO overflow path
1223 - Fix tools build on macOS/Windows/FreeBSD: include endian-shim.h
1224 for be16toh in ristsender.c and ristreceiver.c
1225 - Fix tools build: always compile tunnel_interface/tun_mode into
1226 rist_tools_config_object (consumers reference them unconditionally)
1227 - Fix missing_counter bookkeeping: track queue length instead of
1228 NACK-sent count. Previously the counter stayed at 0 on paths that
1229 never emit NACKs (e.g. simple-profile multicast), causing the
1230 missing_queue JSON stat to under-report and the congestion guard in
1231 receiver_mark_missing to never trip.
1232 - Fix build-only-platform-matching TUN source file; previously the
1233 non-matching src/tun_*.c were compiled into an empty translation
1234 unit and tripped -Werror=pedantic on Ubuntu/MinGW.
1235 - Fix risttunnel build on MinGW: include <windows.h> for Sleep().
1236
1237 Improvements:
1238 - Refactored sender queue management for better memory efficiency
1239 - Improved UDP send reliability with EAGAIN retry
1240 - Improved cname buffer safety
1241 - Refactored flow timeout semantics
1242
1243 Build System:
1244 - TUN support is now always compiled; removed the use_tun meson option
1245 - CI: drop -Duse_tun=true flag from ubuntu build job
1246 - Fix false positive mbedtls detection in meson build
1247 - Use MbedTLS cmake config module
1248 - Check brew exists before calling (macOS)
1249 - Fix compiler warnings in aes.h (Steve Lhomme)
1250
1251 Acknowledgements:
1252 - Dave Evans for RR clock fix
1253 - Steve Lhomme for aes.h warning fixes
1254 - Laur for the receiver FIFO misleading-indentation report
1255
1256
1257 Changes for 0.2.11 (2024-11-15):
1258 --------------------------------
1259
1260 New Features:
1261 - Ephemeral listening ports support (add/remove ports after initialization)
1262 - New function rist_sender_npd_get for null packet deletion status
1263 - New function rist_peer_get_cname to extract peer's private cname
1264 - Enhanced CI test application with packet integrity checks
1265
1266 Bug Fixes:
1267 - Fixed potential socket deadlock condition under MS Windows
1268 - Fixed ristsender confusion with multicast addresses sharing destination port
1269 - Fixed compile warnings under different C++ versions
1270 - Fixed theoretical IP checksum calculation issue
1271 - Fixed ristreceiver closing when tun://@ used in output URL
1272 - Fixed deadlock condition on FIFO overflow
1273 - Fixed invalid verbose-level parameter handling
1274 - Fixed binding to raw UDP socket
1275 - Fixed memory allocation order in stats structures
1276 - Fixed Mac homebrew arm64 build
1277 - Fixed null packet deletion
1278 - Fixed units on sender Prometheus stats
1279 - Fixed keepalive packet data corruption bug
1280 - Fixed improper RTP/RTCP classification (affected ST2110)
1281 - Fixed flow timeout to follow session timeout
1282 - Updated peer config timing_mode field handling
1283
1284 Build:
1285 - Updated meson version to avoid deprecated items
1286
1287 Acknowledgements:
1288 - Special thanks to Thierry Lelegard for null packet deletion bug fix
1289
1290
1291 Changes for 0.2.10 (2023-10-30):
1292 --------------------------------
1293
1294 - Development branch merge with accumulated fixes and improvements
1295
1296
1297 Changes for 0.2.9 (2023-10-11):
1298 -------------------------------
1299
1300 Bug Fixes:
1301 - Fix compilation on 32-bit systems
1302 - Fix regression in stats obj RTT value
1303 - Remove unneeded locking in buffer scaling
1304 - Fix "too old packages" error due to buffer scaling
1305 - Fix empty buffer time check
1306 - Disable buffer negotiation when sender max buffer < receiver buffer
1307 - Fix deadlock caused by wrong lock order when removing peers
1308 - Fix building Prometheus code against older libmicrohttpd
1309 - Fix compilation on Hurd
1310
1311
1312 Changes for 0.2.8 (2023-08-22):
1313 -------------------------------
1314
1315 New Features:
1316 - SRP (Secure Remote Password) passphrase exchange
1317 - Passphrase changing support via U1 bit on M1/M2 packets
1318 - Fully implemented passphrase changing on multicast
1319
1320 Bug Fixes:
1321 - Add GRE check for bit 1 and GRE Ver set to 0
1322 - Fix SIGSEGV when peer_rtcp pointer is null
1323
1324 Improvements:
1325 - Refactored peer matching
1326 - Refactored cryptographic randomness from SRP
1327 - Added peer lock for thread safety
1328 - Default PSK keysize to 256 if not set
1329
1330
1331 Changes for 0.2.7 (2022-04-07):
1332 -------------------------------
1333
1334 New Features:
1335 - Multiplexing support
1336 - TUN (tunnel) interface support
1337
1338
1339 Changes for 0.2.6 (2021-07-22):
1340 -------------------------------
1341
1342 Improvements:
1343 - Move per-packet messages to debug level to prevent log flooding
1344 - Release data earlier when real-time in buffer exceeds 1.1x buffer duration
1345 - Drop stale packets older than 2x buffer duration
1346
1347
1348 Changes for 0.2.5 (2021-07-20):
1349 -------------------------------
1350
1351 - Maintenance release with minor fixes
1352
1353
1354 Changes for 0.2.4 (2021-06-25):
1355 -------------------------------
1356
1357 - Maintenance release with stability improvements
1358
1359
1360 Changes for 0.2.3 (2021-06-22):
1361 -------------------------------
1362
1363 - Maintenance release with bug fixes
1364
1365
1366 Changes for 0.2.2 (2021-06-16):
1367 -------------------------------
1368
1369 - Maintenance release
1370
1371
1372 Changes for 0.2.1 (2021-06-10):
1373 -------------------------------
1374
1375 - Stability fixes for initial public release
1376
1377
1378 Changes for 0.2.0 (2021-05-12):
1379 -------------------------------
1380
1381 Initial official public release of librist.
1382
1383 Core Features:
1384 - Full support for VSF TR-06-1 (Simple Profile)
1385 - VSF TR-06-2 (Main Profile):
1386 * PSK Encryption (AES 128 and 256)
1387 * Bidirectional connection initiation
1388 * Multipath support (load balanced or redundant link bonding)
1389 * One-to-many distribution (media server mode)
1390 * Tested packet recovery up to 50% continuous loss
1391 * Jitter-tolerant output timing
1392
1393 Tools:
1394 - ristsender - RIST sender application
1395 - ristreceiver - RIST receiver application
1396 - rist2rist - RIST relay/proxy application
1397
1398 Platform Support:
1399 - Linux, macOS, Windows, FreeBSD
1400 - Cross-compilation support via meson
1401
1402
1403 Project Information:
1404 --------------------
1405
1406 Website: https://code.videolan.org/rist/librist
1407 License: BSD 2-Clause "Simplified" License