diff --git a/include/libssh/session.h b/include/libssh/session.h index 22256150..03c2bb64 100644 --- a/include/libssh/session.h +++ b/include/libssh/session.h @@ -219,7 +219,7 @@ struct ssh_session_struct { char *custombanner; unsigned long timeout; /* seconds */ unsigned long timeout_usec; - unsigned int port; + uint16_t port; socket_t fd; int StrictHostKeyChecking; char compressionlevel; diff --git a/src/misc.c b/src/misc.c index 0f1a7d49..8d7e2150 100644 --- a/src/misc.c +++ b/src/misc.c @@ -1164,14 +1164,13 @@ char *ssh_path_expand_escape(ssh_session session, const char *s) { x = strdup(session->opts.username); break; case 'p': - if (session->opts.port < 65536) { - char tmp[6]; + if (session->opts.port > 0) { + char tmp[6]; - snprintf(tmp, - sizeof(tmp), - "%u", - session->opts.port > 0 ? session->opts.port : 22); - x = strdup(tmp); + snprintf(tmp, sizeof(tmp), "%hu", + (uint16_t)(session->opts.port > 0 ? session->opts.port + : 22)); + x = strdup(tmp); } break; default: