-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ASAN: invalid handling of scanf("%mc")
format option
#61768
Closed
Labels
compiler-rt:asan
Address sanitizer
false-positive
Warning fires when it should not
release:backport
release:fixed-in-main
release:merged
Milestone
Comments
Thanks for the detailed report. The write range for |
/cherry-pick beeb37a |
/branch llvm/llvm-project-release-prs/issue61768 |
llvmbot
pushed a commit
to llvm/llvm-project-release-prs
that referenced
this issue
Aug 28, 2023
When the optional assignment-allocation character 'm' (Extension to the ISO C standard) is present, we currently use internal_strlen(buf)+1 for all of cCsS[ (D85350). Fix cCS to use the correct size. Fix llvm/llvm-project#61768 Reviewed By: #sanitizers, vitalybuka Differential Revision: https://reviews.llvm.org/D158485 (cherry picked from commit beeb37a8f3275281be305d2d1afe35ca053e21c0)
/pull-request llvm/llvm-project-release-prs#658 |
tru
pushed a commit
to llvm/llvm-project-release-prs
that referenced
this issue
Sep 5, 2023
When the optional assignment-allocation character 'm' (Extension to the ISO C standard) is present, we currently use internal_strlen(buf)+1 for all of cCsS[ (D85350). Fix cCS to use the correct size. Fix llvm/llvm-project#61768 Reviewed By: #sanitizers, vitalybuka Differential Revision: https://reviews.llvm.org/D158485 (cherry picked from commit beeb37a8f3275281be305d2d1afe35ca053e21c0)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
compiler-rt:asan
Address sanitizer
false-positive
Warning fires when it should not
release:backport
release:fixed-in-main
release:merged
Test case with false positive:
The above code fails under
glibc-2.35
(but the responsible code wasn't changed in the last 9 years).Responsible code: https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_format.inc#L347
IMHO it's invalid to assume the NULL character would be appended in case of
%[precision]mc
sostrlen
can't be used here (and +1 is strictly invalid). POSIX-2008:TC2 standard is kind of ambiguous about that, but I've found discussion about changes going into TC3 (when it would be published) which explicitly states that NULL character would be appended ins
case only: https://www.austingroupbugs.net/view.php?id=1173Other standard libraries aside of
glibc
were not inspected.The text was updated successfully, but these errors were encountered: