Commit ad19b26
committed
Fix heap-buffer-overflow in TelnetLayer::getOption(TelnetCommand)
In getOption(TelnetCommand) and getOptionData(TelnetCommand, size_t&),
the 'offset' variable was calculated before getNextCommandField() advanced
'pos', causing a stale value to be used as maxLength in subsequent
getFieldLen() calls. This allowed distanceToNextIAC() to set an endIt
pointer past the end of the allocated buffer, triggering an out-of-bounds
read in std::find() inside findNextIAC().
Fix: recalculate offset from the updated pos after getNextCommandField().
Also fix getOptionData(TelnetCommand, size_t&) which incorrectly used
m_Data instead of pos when extracting field data for the matched command.
Fixes: #21441 parent 6b84492 commit ad19b26
1 file changed
Lines changed: 7 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
373 | | - | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
374 | 377 | | |
375 | 378 | | |
376 | 379 | | |
| |||
417 | 420 | | |
418 | 421 | | |
419 | 422 | | |
420 | | - | |
421 | | - | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
422 | 426 | | |
423 | 427 | | |
424 | 428 | | |
| |||
0 commit comments