ref: Address CWE-676 use of potentially dangerous functions#7549
Open
ref: Address CWE-676 use of potentially dangerous functions#7549
Conversation
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Internal Changes 🔧Samples
Other
🤖 This preview updates automatically when you update the PR. |
Member
Author
|
@sentry review |
philprime
commented
Feb 27, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7549 +/- ##
=============================================
- Coverage 85.186% 85.170% -0.016%
=============================================
Files 490 490
Lines 29520 29543 +23
Branches 12761 12774 +13
=============================================
+ Hits 25147 25162 +15
- Misses 4322 4331 +9
+ Partials 51 50 -1
... and 6 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Member
Author
|
@sentry review |
📲 Install BuildsiOS
|
Contributor
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 787537a | 1218.35 ms | 1251.72 ms | 33.38 ms |
| ffb6adc | 1218.60 ms | 1247.47 ms | 28.87 ms |
| b6fa517 | 1218.83 ms | 1257.47 ms | 38.63 ms |
| df67624 | 1225.12 ms | 1259.90 ms | 34.78 ms |
| a7c42d9 | 1217.25 ms | 1253.98 ms | 36.73 ms |
| 29d546e | 1224.06 ms | 1257.05 ms | 32.98 ms |
| 1c5ecda | 1219.35 ms | 1253.76 ms | 34.41 ms |
| ae8cece | 1216.83 ms | 1251.37 ms | 34.55 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 787537a | 24.14 KiB | 1.15 MiB | 1.12 MiB |
| ffb6adc | 24.14 KiB | 1.15 MiB | 1.12 MiB |
| b6fa517 | 24.14 KiB | 1.14 MiB | 1.12 MiB |
| df67624 | 24.14 KiB | 1.14 MiB | 1.12 MiB |
| a7c42d9 | 24.14 KiB | 1.15 MiB | 1.13 MiB |
| 29d546e | 24.14 KiB | 1.15 MiB | 1.13 MiB |
| 1c5ecda | 24.14 KiB | 1.15 MiB | 1.12 MiB |
| ae8cece | 24.14 KiB | 1.15 MiB | 1.13 MiB |
Replace sscanf with strtoull/strtod in report store and JSON codec to avoid CWE-676 flagged APIs on Apple platforms (scanf_s is unavailable). Add CWE-676 safety comments at all memcpy, strlen, and calloc sites documenting bounds or null-termination guarantees. Keep calloc for zero-initialization; add overflow guards where count*size could overflow (dirContents, image renderer). Add unit tests for report ID parsing and floating-point decode. Fixes #2785
eb59e2f to
c19551a
Compare
Replace terse `// CWE-676: ...` annotations with full-sentence justifications that explain why each strlen/memcpy/calloc call is safe (or why the surrounding refactor avoided UB). Add a test that exercises the production strncmp + strtoull filename parser via sentrycrashcrs_getReportCount, ensuring malformed filenames in the report directory are filtered out.
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.
Address CWE-676 (use of potentially dangerous functions) reported by customer security tools. Replaces sscanf with strtoull/strtod in the report store and JSON codec so we avoid flagged APIs; scanf_s is not available on Apple platforms. Adds CWE-676 safety comments at all memcpy, strlen, and calloc sites documenting bounds or null-termination guarantees. Keeps calloc for zero-initialization and adds overflow guards where count*size could overflow (dirContents, image renderer). Adds unit tests for report ID parsing and floating-point decode.
Fixes #2785