Skip to content

Commit

Permalink
Make separate_json_data_and_signature robust to potential C-style nul…
Browse files Browse the repository at this point in the history
…l terminators
  • Loading branch information
Niederb committed Jan 26, 2023
1 parent 6cbd250 commit 90c466d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core-primitives/attestation-handler/src/collateral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ impl SgxQlQveCollateral {
/// Returns the data part and signature as a pair
fn separate_json_data_and_signature(data_name: &str, data: &[u8]) -> Option<(String, String)> {
let json = String::from_utf8_lossy(data);
let value: serde_json::Value = serde_json::from_str(&json).ok()?;
// Remove potential C-style null terminators
let json = json.trim_matches(char::from(0));
let value: serde_json::Value = serde_json::from_str(json).ok()?;
if value[data_name].is_null() || value["signature"].is_null() {
return None
}
Expand Down

0 comments on commit 90c466d

Please sign in to comment.