Skip to content

Commit

Permalink
safety check to ensure logo url exists
Browse files Browse the repository at this point in the history
  • Loading branch information
AmyrAhmady committed Jun 28, 2024
1 parent 81527ce commit 69c558b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src-tauri/src/query.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use actix_web::web::Buf;
use byteorder::{LittleEndian, ReadBytesExt};
use regex::Regex;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -185,10 +186,12 @@ impl Query {
packet.read_exact(&mut banner_url_buf).unwrap();
data.dark_banner_url = helpers::decode_buffer(banner_url_buf).0;

let logo_url_len = packet.read_u32::<LittleEndian>().unwrap();
let mut logo_url_buf = vec![0u8; logo_url_len as usize];
packet.read_exact(&mut logo_url_buf).unwrap();
data.logo_url = helpers::decode_buffer(logo_url_buf).0;
if packet.remaining() > 0 {
let logo_url_len = packet.read_u32::<LittleEndian>().unwrap();
let mut logo_url_buf = vec![0u8; logo_url_len as usize];
packet.read_exact(&mut logo_url_buf).unwrap();
data.logo_url = helpers::decode_buffer(logo_url_buf).0;
}

Ok(serde_json::to_string(&data).unwrap())
}
Expand Down

0 comments on commit 69c558b

Please sign in to comment.