Skip to content
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

fix: Check for NULL in binary image cache #3469

Merged
merged 6 commits into from
Dec 1, 2023

Conversation

philipphofmann
Copy link
Member

📜 Description

Properly validate the binary image name when converting it to an NSString to avoid crashes.

💡 Motivation and Context

I came across this when looking at #3468.

💚 How did you test it?

Unit tests.

📝 Checklist

You have to check all boxes before merging:

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

Properly validate the binary image name when converting it to an
NSString to avoid crashes.
Copy link

codecov bot commented Nov 30, 2023

Codecov Report

Merging #3469 (3f3bbae) into main (5ab8ec2) will increase coverage by 0.052%.
The diff coverage is 100.000%.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #3469       +/-   ##
=============================================
+ Coverage   88.962%   89.015%   +0.052%     
=============================================
  Files          525       525               
  Lines        56682     56732       +50     
  Branches     20399     20410       +11     
=============================================
+ Hits         50426     50500       +74     
+ Misses        5333      5197      -136     
- Partials       923      1035      +112     
Files Coverage Δ
Sources/Sentry/SentryBinaryImageCache.m 100.000% <100.000%> (ø)
...ests/SentryTests/SentryBinaryImageCacheTests.swift 100.000% <100.000%> (ø)

... and 39 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5ab8ec2...3f3bbae. Read the comment docs.

Copy link
Member

@armcknight armcknight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple questions on possible additional NULL checks we might need.

Sources/Sentry/SentryBinaryImageCache.m Show resolved Hide resolved
Sources/Sentry/SentryBinaryImageCache.m Show resolved Hide resolved
@philipphofmann philipphofmann changed the title fix: Validate image name in binary image cache fix: Check for NULL in binary image cache Dec 1, 2023
Copy link
Contributor

@brustolin brustolin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

But, can this ever happen, the system calling binaryWasAdded but passing NULL?

@philipphofmann
Copy link
Member Author

But, can this ever happen, the system calling binaryWasAdded but passing NULL?

I don't think so, but better to be safe than sorry.

Copy link

github-actions bot commented Dec 1, 2023

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1196.16 ms 1214.84 ms 18.67 ms
Size 21.58 KiB 414.57 KiB 392.99 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
8e76be4 1272.67 ms 1286.38 ms 13.71 ms
e324230 1230.59 ms 1248.20 ms 17.61 ms
7bc3c0d 1259.74 ms 1268.45 ms 8.71 ms
c5ff7b8 1226.68 ms 1235.04 ms 8.36 ms
b9b0f0a 1220.20 ms 1229.27 ms 9.06 ms
f587451 1271.63 ms 1275.90 ms 4.27 ms
326b7eb 1252.86 ms 1259.56 ms 6.70 ms
85b619d 1252.51 ms 1275.33 ms 22.82 ms
98752f3 1240.61 ms 1259.80 ms 19.18 ms
4aea556 1222.94 ms 1248.02 ms 25.08 ms

App size

Revision Plain With Sentry Diff
8e76be4 20.76 KiB 427.66 KiB 406.89 KiB
e324230 22.85 KiB 408.87 KiB 386.02 KiB
7bc3c0d 20.76 KiB 427.35 KiB 406.59 KiB
c5ff7b8 22.85 KiB 414.80 KiB 391.95 KiB
b9b0f0a 20.76 KiB 434.94 KiB 414.18 KiB
f587451 20.76 KiB 435.25 KiB 414.49 KiB
326b7eb 20.76 KiB 432.31 KiB 411.55 KiB
85b619d 20.76 KiB 426.11 KiB 405.35 KiB
98752f3 20.76 KiB 435.09 KiB 414.33 KiB
4aea556 22.85 KiB 411.66 KiB 388.81 KiB

@philipphofmann philipphofmann merged commit bfe863d into main Dec 1, 2023
69 of 70 checks passed
@philipphofmann philipphofmann deleted the fix/handle-image-name-properly-in-image-cache branch December 1, 2023 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants