timeline: when trying to edit/abort on a stale local echo, retry on matching remote echo #3640
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.
It's quite easy for consumers of the UI crate to get a stale
EditInfo
orEventTimelineItem
, when trying to abort/edit an event:EditInfo
orEventTimelineItem
from the local echoEditInfo
/EventTimelineItem
obtained in step 1 would fail, before this patch.So this is some kind of time-of-check/time-of-use bug, with no security implications.
After this patch, we use better strategies, both for edits and redactions:
items
that would now have an event id (== it's been sent), or a matching remote echo (that does have an event id). This covers all the transitions (local echo => local echo with an event id => remote echo with an event id).TimelineItem.identifier()
method, which will get an event id if the local echo has been sent. There's no TOCTOU issue, because theredact()
method takes the event timeline item directly, and not anEditInfo
.Part of #3361.