fix(monitor): chặn cận độ dài khi ghi nhật ký socket chuột, bản dựng hết cảnh báo - #493
Open
nguyenphivn wants to merge 1 commit into
Open
fix(monitor): chặn cận độ dài khi ghi nhật ký socket chuột, bản dựng hết cảnh báo#493nguyenphivn wants to merge 1 commit into
nguyenphivn wants to merge 1 commit into
Conversation
…ng-free Building dev with GCC 16 emits one warning, and this is it: char_traits.h:432:56: warning: '__builtin_memcpy' accessing between 9223372036854775760 and 9223372036854775806 bytes ... [-Wrestrict] inlined from 'void mousePressResetThread()' at src/lotus-monitor.cpp:113 Not a real out-of-bounds read: n comes from recv() into a 16-byte buffer and the n <= 0 case has already returned, so n is in [1, sizeof(buf)] at that point. GCC cannot prove the upper bound, so it assumes the ssize_t could reach size_t range. Clamping the length makes the bound explicit and the build clean. Worth doing because it was the only warning left: one that always shows is one that trains you to skim past the next warning, which may be real. ctest 9/9. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TvNe693ge85eB4QPs6hpjV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Dựng
devbằng GCC 16 thì cả bản dựng chỉ còn đúng một cảnh báo, và đây là nó:Không phải lỗi đọc tràn thật.
nlà giá trịrecvtrả về với đệm 16 byte, và nhánhn <= 0đãbreakở trên, nên tới dòng đónchắc chắn nằm trong[1, sizeof(buf)]. Chỉ là GCC không chứng minh được cận trên nên nó giả địnhssize_tcó thể vọt lên cỡsize_t.Chặn cận làm điều kiện đó thành tường minh, và bản dựng sạch cảnh báo.
Mình nghĩ đáng sửa vì nó là cảnh báo cuối cùng còn lại: một cảnh báo lúc nào cũng hiện sẽ tập cho người ta quen mắt lướt qua, rồi cảnh báo thật sau này cũng bị lướt qua luôn.
ctest9/9.🤖 Generated with Claude Code
https://claude.ai/code/session_01TvNe693ge85eB4QPs6hpjV