fix: panic when empty question qname;

This commit is contained in:
Severin Buhler
2024-02-05 08:23:43 +01:00
parent dab4cb9326
commit 0aef71ed6c
3 changed files with 5 additions and 2 deletions

2
Cargo.lock generated
View File

@@ -1075,7 +1075,7 @@ dependencies = [
[[package]] [[package]]
name = "pkdns" name = "pkdns"
version = "0.2.1" version = "0.2.2"
dependencies = [ dependencies = [
"any-dns", "any-dns",
"chrono", "chrono",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "pkdns" name = "pkdns"
version = "0.2.1" version = "0.2.2"
edition = "2021" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@@ -83,6 +83,9 @@ impl PkarrResolver {
} }
let question = question_opt.unwrap(); let question = question_opt.unwrap();
let labels = question.qname.get_labels(); let labels = question.qname.get_labels();
if labels.len() == 0 {
return Err("No label in question.qname.".into());
};
let raw_pubkey = labels.last().unwrap().to_string(); let raw_pubkey = labels.last().unwrap().to_string();
let parsed_option = Self::parse_pkarr_uri(&raw_pubkey); let parsed_option = Self::parse_pkarr_uri(&raw_pubkey);