Commit 07a0117
committed
fix(log_router): stop buffer overrun
The return value of vsnprintf() is used to determine how long the
message was. However, when vsprintf() truncates a message this value
will exceed the buffer! Then, vprintf_buffer[len] = '\0'; will cause
undefined behaviour.
Add a check for truncation, which resets 'len' to the number of bytes in
the buffer.
Also removed the -1 from the 'size' argument to vsnprintf(), because it
already accounts for the terminating '\0' byte.1 parent 5231302 commit 07a0117
1 file changed
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
126 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
127 | 133 | | |
128 | 134 | | |
129 | 135 | | |
| |||
0 commit comments