Commit fa9f074
Fix panic on short XOR-MAPPED-ADDRESS value
XORMappedAddress.GetFromAs read value[0:2] to decode the address
family before validating the attribute value length. A malformed STUN
message carrying an XOR-MAPPED-ADDRESS attribute with a 0-length value
at the end of a tightly allocated buffer triggered a slice-bounds
runtime panic, since the value slice had no spare capacity to re-slice
into.
Move the length check ahead of the first read so a short value returns
io.ErrUnexpectedEOF instead of panicking. This is remotely triggerable
on normal STUN/ICE Binding-response parsing paths.
Reported by Karolina GORNA
Reported-By: karolina.gorna@ledger.com
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 01aa5b8 commit fa9f074
2 files changed
Lines changed: 19 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
94 | 97 | | |
95 | 98 | | |
96 | 99 | | |
| |||
111 | 114 | | |
112 | 115 | | |
113 | 116 | | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
72 | 88 | | |
73 | 89 | | |
74 | 90 | | |
| |||
0 commit comments