Skip to content

win/wintty: Limit how many digits count can hold - #1254

Closed
mkuoppal wants to merge 1 commit into
NetHack:NetHack-3.7from
mkuoppal:wintty_count_fix
Closed

mkuoppal wants to merge 1 commit into
NetHack:NetHack-3.7from
mkuoppal:wintty_count_fix

Conversation

@mkuoppal

@mkuoppal mkuoppal commented Jun 7, 2024

Copy link
Copy Markdown
Contributor

Debugfuzzer will end up pushing such amount of characters into the count gatherer that we eventually overflow long type.

Limit the count to what signed int could hold. This still allows 8 digits and that should be enough
for practical purposes.

This will prevent long overflow and spurious ubsan reports.

@mkuoppal
mkuoppal force-pushed the wintty_count_fix branch from bb6f393 to 22aaa30 Compare June 7, 2024 14:01
Debugfuzzer will end up pushing such amount of characters
into the count gatherer that we eventually overflow long
type.

Limit the count to what signed int could hold. This
still allows 8 digits and that should be enough
for practical purposes.

This will prevent long overflow and spurious ubsan
reports.
@mkuoppal
mkuoppal force-pushed the wintty_count_fix branch from 22aaa30 to a0c758b Compare June 7, 2024 15:12
@mkuoppal

mkuoppal commented Jun 9, 2024

Copy link
Copy Markdown
Contributor Author

Example of ubsan report when debugfuzzer fills the count calculation into overflow:

../win/tty/wintty.c:1568:28: runtime error: signed integer overflow: 1192464466725874314 * 10 cannot be represented in type 'long int'
#0 0x5bd3ebd09682 in process_menu_window ../win/tty/wintty.c:1568
#1 0x5bd3ebd0e8aa in tty_display_nhwindow ../win/tty/wintty.c:1924
#2 0x5bd3ebd18864 in tty_select_menu ../win/tty/wintty.c:2766
#3 0x5bd3ebc20fbb in select_menu /home/miku/src/NetHack/src/windows.c:1855
#4 0x5bd3eb76218e in doset_simple_menu /home/miku/src/NetHack/src/options.c:8428
#5 0x5bd3eb763c6d in doset_simple /home/miku/src/NetHack/src/options.c:8503
#6 0x5bd3eb04b0c5 in rhack /home/miku/src/NetHack/src/cmd.c:3397
#7 0x5bd3eaf3a3bf in moveloop_core /home/miku/src/NetHack/src/allmain.c:504
#8 0x5bd3eaf3ae53 in moveloop /home/miku/src/NetHack/src/allmain.c:558
#9 0x5bd3ebcdc86f in main ../sys/unix/unixmain.c:323
#10 0x7e1e4f02a1c9 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
#11 0x7e1e4f02a28a in __libc_start_main_impl ../csu/libc-start.c:360
#12 0x5bd3eaf35384 in _start (/home/miku/src/NetHack/src/nethack+0x13ae384) (BuildId: d09985dfa1997f245215878688ea49f109095cbf)

@nhcopier nhcopier closed this in 05cbbc7 Jun 10, 2024
@nhmall

nhmall commented Jul 23, 2024 •

Copy link
Copy Markdown
Contributor

Commit d5785f2 referenced this entry in error (last two digits were transposed).

nhcopier pushed a commit that referenced this pull request Jul 23, 2024
> If there's a trap on a no-dig level, the floor beneath it will always be "too hard to dig into", making it impossible to remove the trap.
>
> As you can still dig pits in these levels (just not holes), the floor under the trap itself resisting to become a pit seems inconsistent.
>
> Steps to reproduce:
>
> Go to no-dig level like Mine's End
> Make a trap
> Dig a pit next to it -> works
> Dig on the trap -> does not work

Return more information about the dig_check() results to caller (was
just a boolean).

Move the messaging that was in dig_check() into a separate
digcheck_fail_message() function that uses the expanded return
information.

Resolves #1254

.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants