fix exploitable security bug in options processing

From a bug report, the function escapes(),
which is used during options parsing for various options that accept
string values, is given user-controlled input that could end with a
backslash or caret (or two character "\M").  Such a malformed escape
sequence would make it consume the input's end-of-string character and
then keep processing whatever followed.  That meant that it could
generate more data than its output buffer was prepared to hold, making
nethack be vulnerable to stack overflow issues.

     His example that was supposed to clobber the stack didn't trigger
any trouble for me, and I didn't bother trying the second one that can
allegedly cause the Win32 binary to run another program.  But the bug
itself is clearly real.
This commit is contained in:
nethack.rankin
2011-08-03 12:42:12 +00:00
parent 28ab93325e
commit 50e12a87aa
2 changed files with 25 additions and 22 deletions

View File

@@ -410,6 +410,9 @@ unlit candelabrum would become unlightable if its candles had exactly 1 turn
temporary loss of Dex from wounded legs will become permanent if it occurs
while mounted and hero dismounts before steed's legs have healed
jaberwocks don't have hands
character escape sequence handling during options processing was vulernable
to malformed escapes and could potentially be abused to clobber the
stack and launch a buffer overrun attack
Platform- and/or Interface-Specific Fixes