util: Fix UB in SetStdinEcho when ENOTTY #34597

pull maflcko wants to merge 2 commits into bitcoin:master from maflcko:2602-less-ub-stdin changing 3 files +11 −11
  1. maflcko commented at 11:37 am on February 16, 2026: member

    The call to tcgetattr may fail with ENOTTY, leaving the struct possibly uninitialized (UB).

    Fix this UB by returning early when isatty fails, or when tcgetattr fails. (Same for Windows)

    This can be tested by a command that fails valgrind before the change and passes after:

    0echo 'pipe' | valgrind --quiet ./bld-cmake/bin/bitcoin-cli -stdinrpcpass uptime
    
  2. util: Fix UB in SetStdinEcho when ENOTTY fa5adfb13e
  3. DrahtBot added the label Utils/log/libs on Feb 16, 2026
  4. DrahtBot commented at 11:37 am on February 16, 2026: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Concept ACK l0rinc

    If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #34004 (Implementation of SwiftSync by rustaceanrob)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  5. l0rinc commented at 12:46 pm on February 16, 2026: contributor
  6. maflcko commented at 1:08 pm on February 16, 2026: member
    No, that is just a harmless warning. I guess I can refactor it a bit while touching this…
  7. refactor: Use static_cast<decltype(...)> to suppress integer sanitizer warning
    This refactor does not change any behavior, except for the integer
    sanitizer warning.
    
    Can be tested via:
    
    UBSAN_OPTIONS="suppressions=$(pwd)/test/sanitizer_suppressions/ubsan:print_stacktrace=1:halt_on_error=1:report_error_type=1" ./bld-cmake/bin/bitcoin-cli -stdinrpcpass uptime
    faff79629c
  8. maflcko commented at 1:53 pm on February 16, 2026: member

    Pushed that as well. Needs compilation with the integer sanitizer (-DSANITIZERS=integer, ref: https://godbolt.org/z/YGjWa89vs) and can be tested via:

    0UBSAN_OPTIONS="suppressions=$(pwd)/test/sanitizer_suppressions/ubsan:print_stacktrace=1:halt_on_error=1:report_error_type=1" ./bld-cmake/bin/bitcoin-cli -stdinrpcpass uptime
    

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-02-17 06:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me