Commit 2cb9a4f
log: Fix unlikely out-of-bounds issue.
In the unlikely case that the overflow check should fail,
the else clause would switch to the truncated stack message
without updating the len variable. This would contain the
return value from vsnprintf(), meaning it could point beyond
the buffer.
The subsequent code which trims NL and CR from the buffer,
would then read -- and possibly write -- out-of-bounds.
To fix this, we split the two joint conditions into separate
if-clauses, and adjust the len variable in the case where we
know the message buffer was truncated.1 parent bc17a89 commit 2cb9a4f
1 file changed
+14
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
612 | 612 | | |
613 | 613 | | |
614 | 614 | | |
615 | | - | |
616 | | - | |
617 | | - | |
618 | | - | |
619 | | - | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
620 | 629 | | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | 630 | | |
625 | 631 | | |
626 | 632 | | |
| |||
0 commit comments