@@ -1321,23 +1321,33 @@ impl OptionsExt for Options {
13211321
13221322 // Network stuff
13231323 if let Some ( ref udp) = args. udp {
1324- if let Some ( at) = udp. find ( '@' ) {
1325- let addr = & udp[ 0 ..at] ;
1326- let port = & udp[ at + 1 ..] ;
1324+ let mut remaining_udp = udp. as_str ( ) ;
13271325
1328- self . udpsrc = Some ( udp. clone ( ) ) ;
1329- self . udpaddr = Some ( addr. to_owned ( ) ) ;
1330- self . udpport = port. parse ( ) . unwrap ( ) ;
1331- } else if let Some ( colon) = udp. find ( ':' ) {
1332- let addr = & udp[ 0 ..colon] ;
1333- let port = get_atoi_hex ( & udp[ colon + 1 ..] ) ;
1326+ if let Some ( at) = remaining_udp. find ( '@' ) {
1327+ let src = & remaining_udp[ 0 ..at] ;
1328+ self . udpsrc = Some ( src. to_owned ( ) ) ;
1329+
1330+ remaining_udp = & remaining_udp[ at + 1 ..] ;
1331+ }
1332+
1333+ if let Some ( colon) = remaining_udp. find ( ':' ) {
1334+ let addr = & remaining_udp[ 0 ..colon] ;
1335+ let port = get_atoi_hex ( & remaining_udp[ colon + 1 ..] ) ;
13341336
1335- self . udpsrc = Some ( udp. clone ( ) ) ;
13361337 self . udpaddr = Some ( addr. to_owned ( ) ) ;
13371338 self . udpport = port;
13381339 } else {
1339- self . udpaddr = None ;
1340- self . udpport = udp. parse ( ) . unwrap ( ) ;
1340+ match remaining_udp. parse ( ) {
1341+ Ok ( port) => {
1342+ self . udpport = port;
1343+ }
1344+ Err ( _) => {
1345+ fatal ! (
1346+ cause = ExitCause :: MalformedParameter ;
1347+ "Invalid UDP parameter\n "
1348+ ) ;
1349+ }
1350+ }
13411351 }
13421352
13431353 self . input_source = DataSource :: Network ;
0 commit comments