Skip to content

Commit

Permalink
nssdb: Fix object search without template
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Jelen <[email protected]>
  • Loading branch information
Jakuje authored and simo5 committed Dec 10, 2024
1 parent 951bd54 commit 152ec71
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/storage/nssdb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,31 +460,34 @@ impl NSSStorage {

/* if neither was excluded we may be asked for both */
if do_private {
query.private = Some(format!(
"SELECT ALL id FROM {} WHERE ",
NSS_PRIVATE_TABLE
));
query.private =
Some(format!("SELECT ALL id FROM {} ", NSS_PRIVATE_TABLE));
}
if do_public {
query.public =
Some(format!("SELECT ALL id FROM {} WHERE ", NSS_PUBLIC_TABLE));
Some(format!("SELECT ALL id FROM {} ", NSS_PUBLIC_TABLE));
}

for idx in 0..template.len() {
static CONCAT: &str = " AND";
static WHERE: &str = " WHERE";
let atype = AttrType::attr_id_to_attrtype(template[idx].type_)?;
let atval = u32::try_from(template[idx].type_)?;

if let Some(ref mut prv) = query.private {
if idx != 0 {
prv.push_str(CONCAT);
} else {
prv.push_str(WHERE);
}
write!(prv, " a{:x} = ?", atval)?;
}

if let Some(ref mut pbl) = query.public {
if idx != 0 {
pbl.push_str(CONCAT);
} else {
pbl.push_str(WHERE);
}
write!(pbl, " a{:x} = ?", atval)?;
}
Expand Down

0 comments on commit 152ec71

Please sign in to comment.