Commit 7bd45cd
net: dns: Fix potential buffer overflow when unpacking labels
As the loop unpacking the DNS name from records checks the current
label length on each iteration, it's also needed to update the remaining
buffer length on each iteration, otherwise the buffer length checks
doesn't work as expected.
Additionally, the remaining buffer checks while technically worked, they
were conceptually wrong and unintuitive. The buf->data pointer doesn't
move, so comparing against this pointer when adding new labels doesn't
make sense. It's more intuitive to simply compare the label size vs
the remaining buffer space.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>1 parent 353dadf commit 7bd45cd
1 file changed
+3
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
486 | 486 | | |
487 | 487 | | |
488 | 488 | | |
489 | | - | |
490 | 489 | | |
491 | 490 | | |
492 | 491 | | |
| |||
525 | 524 | | |
526 | 525 | | |
527 | 526 | | |
| 527 | + | |
| 528 | + | |
528 | 529 | | |
529 | 530 | | |
530 | 531 | | |
| |||
533 | 534 | | |
534 | 535 | | |
535 | 536 | | |
536 | | - | |
537 | | - | |
| 537 | + | |
538 | 538 | | |
539 | 539 | | |
540 | 540 | | |
| |||
0 commit comments