ssh: fix leak and apply style(9) to hostname canonicalization
Fixes: bf2e2524a2ce ("ssh: canonicize the host name before...")
Fixes: 3e74849a1ee2 ("ssh: canonicize the host name before...")
Reviewed by: rew
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38441
(cherry picked from commit 19aba210e1a1b5999bff10cccab5a277060c4d46)
(cherry picked from commit 792d3f16868e5f79ab8b11803340251371515f0a)