fix: invalid typing bytes because of 0xff in numbers

next
Timo Kösters 2020-10-06 20:43:35 +02:00
parent bcd1fe1856
commit c15ae3c126
No known key found for this signature in database
GPG Key ID: 24DA7517711A2BA4
2 changed files with 7 additions and 3 deletions

View File

@ -11,6 +11,7 @@ use ruma::{
use std::{ use std::{
collections::HashMap, collections::HashMap,
convert::{TryFrom, TryInto}, convert::{TryFrom, TryInto},
mem,
}; };
#[derive(Clone)] #[derive(Clone)]
@ -228,9 +229,11 @@ impl RoomEdus {
let key = key?; let key = key?;
Ok::<_, Error>(( Ok::<_, Error>((
key.clone(), key.clone(),
utils::u64_from_bytes(key.split(|&b| b == 0xff).nth(1).ok_or_else(|| { utils::u64_from_bytes(
&key.splitn(2, |&b| b == 0xff).nth(1).ok_or_else(|| {
Error::bad_database("RoomTyping has invalid timestamp or delimiters.") Error::bad_database("RoomTyping has invalid timestamp or delimiters.")
})?) })?[0..mem::size_of::<u64>()],
)
.map_err(|_| Error::bad_database("RoomTyping has invalid timestamp bytes."))?, .map_err(|_| Error::bad_database("RoomTyping has invalid timestamp bytes."))?,
)) ))
}) })

View File

@ -28,6 +28,7 @@ impl Sending {
select! { select! {
Some(server) = futures.next() => { Some(server) = futures.next() => {
warn!("response: {:?}", &server); warn!("response: {:?}", &server);
warn!("futures left: {}", &futures.len());
match server { match server {
Ok((server, _response)) => { Ok((server, _response)) => {
waiting_servers.remove(&server) waiting_servers.remove(&server)