ASAN error in stb_sprintf.h with MSVC
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Start in stb_sprintf.h near the STBSP__ASAN macro around line 158, and check how the existing compiler conditional defines the AddressSanitizer exemption. Compare the MSVC __declspec(no_sanitize_address) spelling in the issue with the existing attribute. Done means MSVC builds with AddressSanitizer and the reported runtime error in stbsp__strlen_limited() is exempted.
Written by the indexing model from the issue text.
Description
(moved issue 1909 https://github.com/nothings/stb/issues/1909 from stb repo)
When compiling stb_sprintf.h with Microsoft MSVC, with Asan enabled, at runtime it will throw an error in stbsp__strlen_limited(). The function knowingly does evil things as a performance optimization. There is already a markup on the function to exempt it from AddressSanitizer checks.
But the markup macro isn't implemented for MSVC. Here is what I did to fix it
--- a/stb_sprintf.h
+++ b/stb_sprintf.h
@@ -158,6 +158,10 @@ PERFORMANCE vs MSVC 2008 32-/64-bit (GCC is even slower than MSVC):
#if defined(__SANITIZE_ADDRESS__) && __SANITIZE_ADDRESS__
#define STBSP__ASAN __attribute__((__no_sanitize_address__))
#endif
+#elif defined(_MSC_VER)
+ #if defined(__SANITIZE_ADDRESS__) && __SANITIZE_ADDRESS__
+ #define STBSP__ASAN __declspec(no_sanitize_address)
+ #endif
#endif
- Dominant language
- C
- Stars
- 18
- Forks
- 5
- Avg merge
- 1m
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nothings/stb_sprintf
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
nothings/stb_sprintf#10 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
nothings/stb_sprintf#8 ·
-
[SECURITY] stbsp_snprintf with count=0 writes null terminator before bufferPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
nothings/stb_sprintf#4 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
nothings/stb_sprintf#20 ·
-
Difficulty 2/5 Under an hour Newbie friendliness 68/100
nothings/stb_sprintf#17 ·
All issues in nothings/stb_sprintf
Similar issues
-
bug severity: medium
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
AlessandroSangiuliano/Uros#1014 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
OpenXiangShan/NEMU#1314 ·
Maintainers usually reply within 1 day
-
`get_options()` repeats the first byte when hex-encoding octet stringsPossibly taken @rue19 claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 85/100
OpenPrinting/cups#1830 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
micropython/micropython#20020 ·
Maintainers usually reply within 1 day