Remove unsafe unwraps causing crashes (#1135)
* Remove unsafe unwraps causing crashes * run fmt * bump version
This commit is contained in:
parent
08b26f9d5d
commit
e9e99956ad
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -5074,7 +5074,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "theseus"
|
name = "theseus"
|
||||||
version = "0.7.0"
|
version = "0.7.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-recursion",
|
"async-recursion",
|
||||||
"async-tungstenite",
|
"async-tungstenite",
|
||||||
@ -5126,7 +5126,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "theseus_gui"
|
name = "theseus_gui"
|
||||||
version = "0.7.0"
|
version = "0.7.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"cocoa 0.25.0",
|
"cocoa 0.25.0",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "theseus"
|
name = "theseus"
|
||||||
version = "0.7.0"
|
version = "0.7.1"
|
||||||
authors = ["Jai A <jaiagr+gpg@pm.me>"]
|
authors = ["Jai A <jaiagr+gpg@pm.me>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
|||||||
@ -146,7 +146,7 @@ impl Metadata {
|
|||||||
.join("metadata.json.bak");
|
.join("metadata.json.bak");
|
||||||
|
|
||||||
if metadata_path.exists() {
|
if metadata_path.exists() {
|
||||||
std::fs::copy(&metadata_path, &metadata_backup_path).unwrap();
|
std::fs::copy(&metadata_path, &metadata_backup_path)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
write(
|
write(
|
||||||
@ -154,8 +154,7 @@ impl Metadata {
|
|||||||
&serde_json::to_vec(&metadata_fetch)?,
|
&serde_json::to_vec(&metadata_fetch)?,
|
||||||
&state.io_semaphore,
|
&state.io_semaphore,
|
||||||
)
|
)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let mut old_metadata = state.metadata.write().await;
|
let mut old_metadata = state.metadata.write().await;
|
||||||
*old_metadata = metadata_fetch;
|
*old_metadata = metadata_fetch;
|
||||||
|
|||||||
@ -34,6 +34,8 @@ pub enum MinecraftAuthStep {
|
|||||||
|
|
||||||
#[derive(thiserror::Error, Debug)]
|
#[derive(thiserror::Error, Debug)]
|
||||||
pub enum MinecraftAuthenticationError {
|
pub enum MinecraftAuthenticationError {
|
||||||
|
#[error("Error reading public key during generation")]
|
||||||
|
ReadingPublicKey,
|
||||||
#[error("Failed to serialize private key to PEM: {0}")]
|
#[error("Failed to serialize private key to PEM: {0}")]
|
||||||
PEMSerialize(#[from] p256::pkcs8::Error),
|
PEMSerialize(#[from] p256::pkcs8::Error),
|
||||||
#[error("Failed to serialize body to JSON during step {step:?}: {source}")]
|
#[error("Failed to serialize body to JSON during step {step:?}: {source}")]
|
||||||
@ -63,6 +65,8 @@ pub enum MinecraftAuthenticationError {
|
|||||||
#[source]
|
#[source]
|
||||||
source: std::io::Error,
|
source: std::io::Error,
|
||||||
},
|
},
|
||||||
|
#[error("Error reading XBOX Session ID header")]
|
||||||
|
NoSessionId,
|
||||||
#[error("Error reading user hash")]
|
#[error("Error reading user hash")]
|
||||||
NoUserHash,
|
NoUserHash,
|
||||||
}
|
}
|
||||||
@ -415,7 +419,7 @@ async fn sisu_authenticate(
|
|||||||
let session_id = headers
|
let session_id = headers
|
||||||
.get("X-SessionId")
|
.get("X-SessionId")
|
||||||
.and_then(|x| x.to_str().ok())
|
.and_then(|x| x.to_str().ok())
|
||||||
.unwrap()
|
.ok_or_else(|| MinecraftAuthenticationError::NoSessionId)?
|
||||||
.to_string();
|
.to_string();
|
||||||
|
|
||||||
Ok((session_id, res))
|
Ok((session_id, res))
|
||||||
@ -760,8 +764,16 @@ fn generate_key() -> Result<DeviceTokenKey, MinecraftAuthenticationError> {
|
|||||||
Ok(DeviceTokenKey {
|
Ok(DeviceTokenKey {
|
||||||
id,
|
id,
|
||||||
key: signing_key,
|
key: signing_key,
|
||||||
x: BASE64_URL_SAFE_NO_PAD.encode(encoded_point.x().unwrap()),
|
x: BASE64_URL_SAFE_NO_PAD.encode(
|
||||||
y: BASE64_URL_SAFE_NO_PAD.encode(encoded_point.y().unwrap()),
|
encoded_point.x().ok_or_else(|| {
|
||||||
|
MinecraftAuthenticationError::ReadingPublicKey
|
||||||
|
})?,
|
||||||
|
),
|
||||||
|
y: BASE64_URL_SAFE_NO_PAD.encode(
|
||||||
|
encoded_point.y().ok_or_else(|| {
|
||||||
|
MinecraftAuthenticationError::ReadingPublicKey
|
||||||
|
})?,
|
||||||
|
),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -232,24 +232,26 @@ async fn read_icon_from_file(
|
|||||||
zip_file_reader.file().entries().iter().position(|f| {
|
zip_file_reader.file().entries().iter().position(|f| {
|
||||||
f.filename().as_str().unwrap_or_default() == icon_path
|
f.filename().as_str().unwrap_or_default() == icon_path
|
||||||
});
|
});
|
||||||
let mut bytes = Vec::new();
|
if let Some(zip_index) = zip_index_option {
|
||||||
if zip_file_reader
|
let mut bytes = Vec::new();
|
||||||
.reader_with_entry(zip_index_option.unwrap())
|
if zip_file_reader
|
||||||
.await?
|
.reader_with_entry(zip_index)
|
||||||
.read_to_end_checked(&mut bytes)
|
.await?
|
||||||
.await
|
.read_to_end_checked(&mut bytes)
|
||||||
.is_ok()
|
.await
|
||||||
{
|
.is_ok()
|
||||||
let bytes = bytes::Bytes::from(bytes);
|
{
|
||||||
let path = write_cached_icon(
|
let bytes = bytes::Bytes::from(bytes);
|
||||||
&icon_path,
|
let path = write_cached_icon(
|
||||||
cache_dir,
|
&icon_path,
|
||||||
bytes,
|
cache_dir,
|
||||||
io_semaphore,
|
bytes,
|
||||||
)
|
io_semaphore,
|
||||||
.await?;
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
return Ok(Some(path));
|
return Ok(Some(path));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -101,8 +101,7 @@ impl Tags {
|
|||||||
&serde_json::to_vec(&tags_fetch)?,
|
&serde_json::to_vec(&tags_fetch)?,
|
||||||
&state.io_semaphore,
|
&state.io_semaphore,
|
||||||
)
|
)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let mut old_tags = state.tags.write().await;
|
let mut old_tags = state.tags.write().await;
|
||||||
*old_tags = tags_fetch;
|
*old_tags = tags_fetch;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "theseus_gui",
|
"name": "theseus_gui",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.7.0",
|
"version": "0.7.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "theseus_gui"
|
name = "theseus_gui"
|
||||||
version = "0.7.0"
|
version = "0.7.1"
|
||||||
description = "A Tauri App"
|
description = "A Tauri App"
|
||||||
authors = ["you"]
|
authors = ["you"]
|
||||||
license = ""
|
license = ""
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
},
|
},
|
||||||
"package": {
|
"package": {
|
||||||
"productName": "Modrinth App",
|
"productName": "Modrinth App",
|
||||||
"version": "0.7.0"
|
"version": "0.7.1"
|
||||||
},
|
},
|
||||||
"tauri": {
|
"tauri": {
|
||||||
"allowlist": {
|
"allowlist": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user