mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
kh2reg: fix Python 3 iterator bug with multiple hostnames.
A known_hosts line can have multiple comma-separated hostnames on it, or more usually a hostname and an IP address. In the RSA and DSA key handlers, I was making a list of the integer parameters of the public key by using the 'map' function, and then iterating over it once per hostname on the line. But in Python 3, the 'map' function returns an iterator, not a list, so after you've iterated to its end once, it's empty, and iterating over it a second time stops immediately. As a result, the registry line for the second hostname was coming out empty.
This commit is contained in:
parent
bed4e12f15
commit
143f8a2d10
@ -225,7 +225,7 @@ def handle_line(line, output_formatter, try_hosts):
|
||||
# Treat as SSH-1-type host key.
|
||||
# Format: hostpat bits10 exp10 mod10 comment...
|
||||
# (PuTTY doesn't store the number of bits.)
|
||||
keyparams = map (int, fields[2:4])
|
||||
keyparams = list(map(int, fields[2:4]))
|
||||
keytype = "rsa"
|
||||
|
||||
else:
|
||||
@ -259,12 +259,12 @@ def handle_line(line, output_formatter, try_hosts):
|
||||
keytype = "rsa2"
|
||||
# The rest of the subfields we can treat as an opaque list
|
||||
# of bignums (same numbers and order as stored by PuTTY).
|
||||
keyparams = map (strtoint, subfields[1:])
|
||||
keyparams = list(map(strtoint, subfields[1:]))
|
||||
|
||||
elif sshkeytype == "ssh-dss":
|
||||
keytype = "dss"
|
||||
# Same again.
|
||||
keyparams = map (strtoint, subfields[1:])
|
||||
keyparams = list(map(strtoint, subfields[1:]))
|
||||
|
||||
elif sshkeytype in nist_curves:
|
||||
keytype = sshkeytype
|
||||
|
Loading…
Reference in New Issue
Block a user