diff options
author | Anders Kaseorg <andersk@mit.edu> | 2016-05-09 03:01:32 -0400 |
---|---|---|
committer | Anders Kaseorg <andersk@mit.edu> | 2016-05-09 03:01:32 -0400 |
commit | 4c7200c016bf29d6e4c4fcbbc0305d0743642096 (patch) | |
tree | 57eceaca29959982c33cca058f3ff7da2078aa28 /scripts | |
parent | d636845c8d2e7cde2303e5fa30a3bc6562080593 (diff) |
--experimental-remote-ip=local: Substitute the IP more carefully
For example, do not interpret regex metacharacters within the
hostname, and avoid accidentally matching the username part of
username@hostname when they happen to match.
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/mosh.pl | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/scripts/mosh.pl b/scripts/mosh.pl index c6fc632..b89086a 100755 --- a/scripts/mosh.pl +++ b/scripts/mosh.pl @@ -302,11 +302,7 @@ $ENV{ 'MOSH_CLIENT_PID' } = $$; # We don't support this, but it's useful for tes my $ip; if ( $use_remote_ip eq 'local' ) { # "parse" the host from what the user gave us - my $host = $userhost; - $host =~ s/.*@//; - if ( !defined $host ) { - die( "could not find hostname in $userhost" ); - } + my ($user, $host) = $userhost =~ /^((?:.*@)?)(.*)$/; # get list of addresses my @res = resolvename( $host, 22, $family ); # Use only the first address as the Mosh IP @@ -319,7 +315,7 @@ if ( $use_remote_ip eq 'local' ) { die( "could not use address for $host" ); } $ip = $addr_string; - $userhost =~ s/${host}/${ip}/; + $userhost = "$user$ip"; } my $pid = open(my $pipe, "-|"); |