ref: Address CWE-676 use of potentially dangerous functions#7549
ref: Address CWE-676 use of potentially dangerous functions#7549
Conversation
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
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. |
|
@sentry review |
| // Parses a floating point number from the string buffer into value using %lg format | ||
| // %lg uses shortest decimal representation and removes trailing zeros | ||
| sscanf(context->stringBuffer, "%lg", &value); | ||
| value = strtod(context->stringBuffer, NULL); |
There was a problem hiding this comment.
Need to double-check if this is truly the same
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #7549 +/- ##
=============================================
- Coverage 85.268% 85.241% -0.028%
=============================================
Files 485 485
Lines 28837 28852 +15
Branches 12525 12528 +3
=============================================
+ Hits 24589 24594 +5
- Misses 4200 4211 +11
+ Partials 48 47 -1
... and 3 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
|
@sentry review |
Sentry Build Distribution
|
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 142ed2c | 1210.67 ms | 1234.21 ms | 23.54 ms |
| d8d010b | 1219.43 ms | 1246.61 ms | 27.19 ms |
| c9976e2 | 1219.31 ms | 1245.44 ms | 26.13 ms |
| b87b34f | 1203.00 ms | 1237.17 ms | 34.17 ms |
| 2b4e787 | 1226.06 ms | 1258.65 ms | 32.59 ms |
| 6de4555 | 1196.67 ms | 1223.98 ms | 27.31 ms |
| 69a0c94 | 1217.85 ms | 1246.98 ms | 29.13 ms |
| 7c58690 | 1221.85 ms | 1230.54 ms | 8.69 ms |
| 45eb835 | 1216.00 ms | 1248.48 ms | 32.48 ms |
| 164f67b | 1220.88 ms | 1248.00 ms | 27.12 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 142ed2c | 24.14 KiB | 1.10 MiB | 1.08 MiB |
| d8d010b | 24.14 KiB | 1.12 MiB | 1.10 MiB |
| c9976e2 | 24.14 KiB | 1.11 MiB | 1.09 MiB |
| b87b34f | 24.14 KiB | 1.06 MiB | 1.04 MiB |
| 2b4e787 | 24.14 KiB | 1.07 MiB | 1.04 MiB |
| 6de4555 | 24.14 KiB | 1.11 MiB | 1.09 MiB |
| 69a0c94 | 24.14 KiB | 1.11 MiB | 1.09 MiB |
| 7c58690 | 24.14 KiB | 1.08 MiB | 1.06 MiB |
| 45eb835 | 24.14 KiB | 1.07 MiB | 1.04 MiB |
| 164f67b | 24.14 KiB | 1.12 MiB | 1.10 MiB |
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