Skip to content

Commit 79697a3

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

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
@@ -178,12 +178,18 @@ pub mod sync {
178178
Some(result) => result,
179179
};
180180

181-
let inner = &room_event
181+
let inner = match room_event
182182
.event
183183
// TODO: UNSAFE CAST - someone evil could encrypt something that
184184
// isn't a state event.
185185
.deserialize_as_unchecked::<AnySyncStateEvent>()
186-
.unwrap();
186+
{
187+
Ok(inner) => inner,
188+
Err(e) => {
189+
warn!("Malformed event body: {e}");
190+
continue;
191+
}
192+
};
187193

188194
// Check event types match, discard if not.
189195
let inner_event_type = inner.event_type().to_string();
@@ -208,7 +214,7 @@ pub mod sync {
208214
continue;
209215
}
210216

211-
room_info.handle_state_event(inner);
217+
room_info.handle_state_event(&inner);
212218
}
213219
}
214220
}

0 commit comments

Comments
 (0)