Fixed a crash when an avatar with a too-big size is being parsed.

This commit is contained in:
Werner Kroneman 2023-12-03 14:38:35 +01:00
parent 4daeaf362f
commit 13449b195c

View file

@ -30,8 +30,9 @@ pub(crate) async fn handle_metadata_pubsub_event(
for item in items {
let payload = item.payload.clone().unwrap();
if payload.is("metadata", ns::AVATAR_METADATA) {
let metadata = Metadata::try_from(payload).unwrap();
for info in metadata.infos {
match Metadata::try_from(payload) {
Ok(metadata) => for info in metadata.infos {
let filename = format!("data/{}/{}", from, &*info.id.to_hex());
let file_length = match fs::metadata(filename.clone()) {
Ok(metadata) => metadata.len(),
@ -45,6 +46,10 @@ pub(crate) async fn handle_metadata_pubsub_event(
let _ = agent.client.send_stanza(iq.into()).await;
}
}
Err(e) => error!("Error parsing avatar metadata: {}", e)
}
}
}
events