Skip to content

Commit 7898a1a

Browse files
committed
feat(base): error handling for malformed encrypted state events
Signed-off-by: Skye Elliot <[email protected]>
1 parent 3bfe988 commit 7898a1a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

crates/matrix-sdk-base/src/response_processors/state_events.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,18 @@ pub mod sync {
170170
Some(result) => result,
171171
};
172172

173-
let inner = &room_event
173+
let inner = match room_event
174174
.event
175175
// TODO: UNSAFE CAST - someone evil could encrypt something that
176176
// isn't a state event.
177177
.deserialize_as_unchecked::<AnySyncStateEvent>()
178-
.unwrap();
178+
{
179+
Ok(inner) => inner,
180+
Err(e) => {
181+
warn!("Malformed event body: {e}");
182+
continue;
183+
}
184+
};
179185

180186
// Check event types match, discard if not.
181187
let inner_event_type = inner.event_type().to_string();
@@ -200,7 +206,7 @@ pub mod sync {
200206
continue;
201207
}
202208

203-
room_info.handle_state_event(inner);
209+
room_info.handle_state_event(&inner);
204210
}
205211
}
206212
}

0 commit comments

Comments
 (0)