Skip to content

Commit

Permalink
nssdb: Fix parsing multiple parameters
Browse files Browse the repository at this point in the history
Previously, the parsing of multiple parameters did not continue
from the previous offset, but reverted back to the start of the
string when we went through multiple parameters.

The follow-up parameters also had a leading space separator
character, which prevented matching it against the defined names.

Signed-off-by: Jakub Jelen <[email protected]>
  • Loading branch information
Jakuje committed Dec 11, 2024
1 parent b09c082 commit 15f8c74
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/storage/nssdb/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl NSSConfig {
return Err(CKR_ARGUMENTS_BAD)?;
}

name = String::from_utf8_lossy(&args[0..idx]).to_lowercase();
name = String::from_utf8_lossy(&args[0..idx]).trim().to_lowercase();

let find = match char::from(args[idx + 1]) {
'\'' => b'\'',
Expand All @@ -120,7 +120,7 @@ impl NSSConfig {

while idx < args.len() {
if let Some(pos) = args[idx..].iter().position(|&x| x == find) {
idx = pos;
idx += pos;

/* backtrack check for escapes */
let mut esc = 0;
Expand Down Expand Up @@ -191,7 +191,7 @@ impl NSSConfig {
let mut idx = 0usize;

while idx < bargs.len() {
idx = config.parse_parameter(&bargs[idx..])?;
idx += config.parse_parameter(&bargs[idx..])?;
}
Ok(config)
}
Expand Down

0 comments on commit 15f8c74

Please sign in to comment.