mirror of
https://github.com/coturn/coturn.git
synced 2026-10-24 00:08:57 +03:00
Repro: build so `TURN_SOFTWARE` is longer than 120 bytes (e.g. a long `-DTURN_SERVER_BUILD_INFO`), run with `--rfc3489-compatibility` and `--software-attribute`, then send a legacy RFC 3489 Binding request. ASan reports a `stack-buffer-overflow` WRITE at the `memcpy` in `handle_old_stun_command`. Cause: the SERVER/SOFTWARE string is copied into `uint8_t software[120]` via `memcpy(software, get_version(server), oldsz)`. The neighbouring `if (newsz > sizeof(software))` clamp bounds `newsz` (the attribute length) but never `oldsz`, so the copy length stays uncapped. Both old-STUN response sites carry it. Fix: bound the copy to `min(oldsz, sizeof(software))`. `oldsz` can be shorter than the rounded-up `newsz`, so copying `newsz` would over-read the source; the buffer is zero-initialised so the trailing pad bytes stay zero.