--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>
This commit is contained in:
+2
-6
@@ -302,11 +302,7 @@ $ENV{ 'MOSH_CLIENT_PID' } = $$; # We don't support this, but it's useful for tes
|
|||||||
my $ip;
|
my $ip;
|
||||||
if ( $use_remote_ip eq 'local' ) {
|
if ( $use_remote_ip eq 'local' ) {
|
||||||
# "parse" the host from what the user gave us
|
# "parse" the host from what the user gave us
|
||||||
my $host = $userhost;
|
my ($user, $host) = $userhost =~ /^((?:.*@)?)(.*)$/;
|
||||||
$host =~ s/.*@//;
|
|
||||||
if ( !defined $host ) {
|
|
||||||
die( "could not find hostname in $userhost" );
|
|
||||||
}
|
|
||||||
# get list of addresses
|
# get list of addresses
|
||||||
my @res = resolvename( $host, 22, $family );
|
my @res = resolvename( $host, 22, $family );
|
||||||
# Use only the first address as the Mosh IP
|
# 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" );
|
die( "could not use address for $host" );
|
||||||
}
|
}
|
||||||
$ip = $addr_string;
|
$ip = $addr_string;
|
||||||
$userhost =~ s/${host}/${ip}/;
|
$userhost = "$user$ip";
|
||||||
}
|
}
|
||||||
|
|
||||||
my $pid = open(my $pipe, "-|");
|
my $pid = open(my $pipe, "-|");
|
||||||
|
|||||||
Reference in New Issue
Block a user