From 17f68a9c35cd7e8772244e4c27832749c631a474 Mon Sep 17 00:00:00 2001 From: Eduardo Pinho Date: Sat, 11 Jan 2025 09:52:17 +0000 Subject: [PATCH] [findscu][scpproxy][storescp][storescu] Pre-validate max PDU length option --- findscu/src/main.rs | 6 +++++- scpproxy/src/main.rs | 2 +- storescp/src/main.rs | 7 ++++++- storescu/src/main.rs | 6 +++++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/findscu/src/main.rs b/findscu/src/main.rs index 4aaeb3fa..6c80f583 100644 --- a/findscu/src/main.rs +++ b/findscu/src/main.rs @@ -45,7 +45,11 @@ struct App { #[arg(long = "called-ae-title")] called_ae_title: Option, /// the maximum PDU length - #[arg(long = "max-pdu-length", default_value = "16384")] + #[arg( + long = "max-pdu-length", + default_value = "16384", + value_parser(clap::value_parser!(u32).range(4096..=131_072)) + )] max_pdu_length: u32, /// use patient root information model diff --git a/scpproxy/src/main.rs b/scpproxy/src/main.rs index a4d2543d..8834220b 100644 --- a/scpproxy/src/main.rs +++ b/scpproxy/src/main.rs @@ -277,7 +277,7 @@ fn command() -> Command { .help("Maximum PDU length") .short('m') .long("max-pdu-length") - .value_parser(value_parser!(u32).range(4096..)) + .value_parser(value_parser!(u32).range(4096..=131_072)) .default_value("16384"), ) } diff --git a/storescp/src/main.rs b/storescp/src/main.rs index d1b29124..08946f39 100644 --- a/storescp/src/main.rs +++ b/storescp/src/main.rs @@ -36,7 +36,12 @@ struct App { #[arg(long)] promiscuous: bool, /// Maximum PDU length - #[arg(short = 'm', long = "max-pdu-length", default_value = "16384")] + #[arg( + short = 'm', + long = "max-pdu-length", + default_value = "16384", + value_parser(clap::value_parser!(u32).range(4096..=131_072)) + )] max_pdu_length: u32, /// Output directory for incoming objects #[arg(short = 'o', default_value = ".")] diff --git a/storescu/src/main.rs b/storescu/src/main.rs index 4b153772..851fef69 100644 --- a/storescu/src/main.rs +++ b/storescu/src/main.rs @@ -46,7 +46,11 @@ struct App { #[arg(long = "called-ae-title")] called_ae_title: Option, /// the maximum PDU length accepted by the SCU - #[arg(long = "max-pdu-length", default_value = "16384")] + #[arg( + long = "max-pdu-length", + default_value = "16384", + value_parser(clap::value_parser!(u32).range(4096..=131_072)) + )] max_pdu_length: u32, /// fail if not all DICOM files can be transferred #[arg(long = "fail-first")]