Commit 4f12c80
committed
dns: fix EDNS0ClientSubnet address truncation for non-octet-aligned prefix lengths
When source_plen is set to a value whose ceil(plen/8) byte count exceeds
the number of non-zero bytes in the address (e.g. source_plen=23 for
101.132.0.0), _pack_subnet incorrectly stripped the trailing zero byte,
producing a 2-byte address instead of the required 3 bytes.
Per RFC 7871, the ADDRESS field MUST be truncated to ceil(source_plen/8)
bytes. Fix _pack_subnet to accept an optional plen parameter and apply
RFC-compliant truncation when it is provided. i2m and i2len now pass
pkt.source_plen so the correct byte count is used during packet building.
Fixes: #49421 parent 9ae49f8 commit 4f12c80
2 files changed
Lines changed: 44 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
558 | 558 | | |
559 | 559 | | |
560 | 560 | | |
561 | | - | |
562 | | - | |
| 561 | + | |
| 562 | + | |
563 | 563 | | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
564 | 571 | | |
565 | 572 | | |
566 | 573 | | |
| |||
571 | 578 | | |
572 | 579 | | |
573 | 580 | | |
| 581 | + | |
574 | 582 | | |
575 | | - | |
| 583 | + | |
576 | 584 | | |
577 | 585 | | |
578 | | - | |
| 586 | + | |
579 | 587 | | |
580 | 588 | | |
581 | 589 | | |
582 | 590 | | |
583 | 591 | | |
| 592 | + | |
584 | 593 | | |
585 | | - | |
| 594 | + | |
586 | 595 | | |
587 | 596 | | |
588 | | - | |
| 597 | + | |
589 | 598 | | |
590 | 599 | | |
591 | 600 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
157 | 186 | | |
158 | 187 | | |
159 | 188 | | |
| |||
0 commit comments