Skip to content

Commit e1e028d

Browse files
committed
fix(cli): Check frame ID lengths on cmdline
Without this, rsid3 interprets something invalid like --XD as a getter and attempts to create an XD text frame, triggering a panic from within the id3 crate. In ID3v2.3 and ID3v2.4, all frames IDs are guaranteed a length of 4. This will get changed as support for ID3v2.2 gets added later.
1 parent 6cc09c1 commit e1e028d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/cli.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ impl Cli {
500500

501501
/// Checks if a command-line argument is a getter argument.
502502
fn is_getter_arg(arg: &str) -> bool {
503-
arg.starts_with("--") && (arg[2..]).chars()
503+
arg.len() == 6 && arg.starts_with("--") && (arg[2..]).chars()
504504
.all(|c| c.is_ascii_uppercase() || c.is_ascii_digit())
505505
}
506506

@@ -520,7 +520,7 @@ impl Cli {
520520

521521
/// Checks if a command-line argument is a delete argument.
522522
fn is_delete_arg(arg: &str) -> bool {
523-
arg.len() > 3 && arg.starts_with("--") && arg.ends_with('-')
523+
arg.len() == 7 && arg.starts_with("--") && arg.ends_with('-')
524524
&& (arg[2..(arg.len() - 1)]).chars() .all(|c| c.is_ascii_uppercase() || c.is_ascii_digit())
525525
}
526526
}

0 commit comments

Comments
 (0)