priv: reject double-quotes in nspawn flag entries
This commit is contained in:
parent
aa7f8e5553
commit
a922376778
1 changed files with 10 additions and 6 deletions
|
|
@ -352,13 +352,17 @@ fn agent_flake_ref(name: &str) -> String {
|
|||
format!("{META_DIR}#{name}")
|
||||
}
|
||||
|
||||
/// Validate one nspawn flag entry: must be non-empty and contain no
|
||||
/// ASCII whitespace or null bytes. Whitespace would split the entry
|
||||
/// into multiple flags when the start script expands
|
||||
/// `$EXTRA_NSPAWN_FLAGS` unquoted.
|
||||
/// Validate one nspawn flag entry. Must be non-empty and contain no
|
||||
/// ASCII whitespace (would split the entry when the start script
|
||||
/// expands `$EXTRA_NSPAWN_FLAGS` unquoted), double-quotes (would
|
||||
/// break the `EXTRA_NSPAWN_FLAGS="..."` conf line), or null bytes.
|
||||
fn validate_nspawn_flag(flag: &str) -> Result<()> {
|
||||
if flag.is_empty() || flag.bytes().any(|b| b == 0 || b.is_ascii_whitespace()) {
|
||||
bail!("invalid nspawn flag {flag:?}: must be non-empty and contain no whitespace or null bytes");
|
||||
if flag.is_empty()
|
||||
|| flag.bytes().any(|b| b == 0 || b == b'"' || b.is_ascii_whitespace())
|
||||
{
|
||||
bail!(
|
||||
"invalid nspawn flag {flag:?}: must be non-empty and contain no whitespace, double-quotes, or null bytes"
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue