mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 16:02:38 +00:00
log: escape C1 control characters in messages #36536
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36536
Loading…
Reference in a new issue
No description provided.
Delete branch "logging-escape-c1"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The log escapes control characters so that a message cannot drive the terminal it is printed on, but it lets through the UTF-8 form of the C1 controls U+0080 to U+009F. VTE, the library behind GNOME Terminal and others, decodes these as CSI, OSC, DCS and the rest, like their
ESC [,ESC ]andESC Pforms.I escape the two-byte sequences 0xC2 0x80 to 0xC2 0x9F as
\xc2\x9band so on. Since 0xC2 is never a continuation byte, this needs no UTF-8 decoder, and all other non-ASCII text still passes untouched, as asked in #17095 and #35833. Single bytes 0x80 to 0x9F stay as they are, since they occur inside valid UTF-8. The new cases intest_LogEscapeMessagefail on master and pass with the change.The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.Conflicts
No conflicts as of last run.
Base:
de96f3ae6d163e97a2cf29bbd7c2bf2d56e11019Head:
40bb43f158bea7e2efdecff0e17d59d9bf32b924No verified findings are available from this review.
Review coverage was incomplete.
Review limitations
Full review report
🐙 This pull request conflicts with the target branch and needs rebase.
ACK
40bb43f158tACK
40bb43f158test_LogEscapeMessage passes
tACK
40bb43f158Tested on Linux x86_64 (Ubuntu 24.04), g++ 13.3.0, Release:
logging_testspass, also with this branch merged onto current master (de96f3ae). With U+009B and U+009F in a regtest datadir path, debug.log has\xc2\x9band\xc2\x9fon this branch and the raw bytes on the merge-base.Nit: the two new checks don't independently pin down both boundaries. Changing the lower bound to
>= 0x7for the end check toi + 1 <= str.size()still passes them. The trailing\xc2in the second check is a string literal, sostr[str.size()]reads the terminating NUL.Adding after line 141:
Both pass on this branch. Each fails only with its corresponding mutant (lines 142 and 143, respectively; Debian 13 x86_64, GCC 14.2.0, Release).
Nit: the
LogEscapeMessagedoc comment and the test comment "ASCII and UTF-8 must pass through unaltered" don't mention the C1 exception. Also, U+0100 isn't adjacent to the tested range: that case checks a different lead byte followed by0x80. The test itself is fine; only the comment is misleading.@cyb3ralbert thanks, both nits are right: the two extra checks pin each boundary, and the comments should mention the C1 exception. I will apply them in a push if a maintainer prefers, and otherwise leave the head as it is, so the three reviews of
40bb43f158stay valid.