Commit 031c1e0
osce: Clamp pitch embedding index to prevent OOB read
The LACE and NoLACE feature networks access the pitch embedding table
using periods[i_subframe] as a direct index without bounds checking.
SILK's decode_pitch() clamps pitch lags to [min_lag, max_lag] where
max_lag = PE_MAX_LAG_MS * Fs_kHz = 288 at 16kHz. If a model is trained
with pitch_max < 288 (the Python training defaults use pitch_max=257),
pitch lag values in the range [pitch_max+1, 288] would read past the
end of the embedding weight table.
Add IMIN/IMAX clamping to bound the pitch index to [0, *_PITCH_MAX]
before the embedding lookup, consistent with how FARGAN handles pitch
embedding access in fargan.c:53.
The current shipped model (v1.6.1) uses pitch_max=300 which covers the
full SILK pitch range, but the C code should defensively clamp regardless
of model parameters.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 788cc89 commit 031c1e0
1 file changed
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| 186 | + | |
186 | 187 | | |
187 | | - | |
| 188 | + | |
188 | 189 | | |
189 | 190 | | |
190 | 191 | | |
| |||
454 | 455 | | |
455 | 456 | | |
456 | 457 | | |
| 458 | + | |
457 | 459 | | |
458 | | - | |
| 460 | + | |
459 | 461 | | |
460 | 462 | | |
461 | 463 | | |
| |||
0 commit comments