Page MenuHomePhabricator

[native] Avoid copy-constructing CryptoModule
ClosedPublic

Authored by ashoat on Oct 22 2023, 9:05 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 10, 12:20 AM
Unknown Object (File)
Mon, Oct 28, 3:47 PM
Unknown Object (File)
Oct 4 2024, 1:46 AM
Unknown Object (File)
Oct 4 2024, 1:46 AM
Unknown Object (File)
Oct 4 2024, 1:46 AM
Unknown Object (File)
Oct 4 2024, 1:46 AM
Unknown Object (File)
Oct 4 2024, 1:43 AM
Unknown Object (File)
Sep 18 2024, 7:00 PM
Subscribers

Details

Summary

See explanation here for why it's unsafe to copy-construct CryptoModule. Basically, the accountBuffer contains memory that represents an olm::Account, which includes members that are olm::Lists. olm::Lists contains a member that is a pointer to another member, which makes it unsafe to copy the accountBuffer wholesale.

This diff changes the code in NotificationsCryptoModule to construct its CryptoModule on the heap as a unique_ptr. We then pass that pointer around, avoiding any need to copy the CryptoModule.

The next diff will remove the copy constructor from CryptoModule to make sure nobody makes this mistake again.

Depends on D9560

Test Plan

I made sure notifs still worked in my local environment (iOS simulator running dev build, along with keyserver connected to APNs in dev mode)

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable