diff --git a/include/libssh/session.h b/include/libssh/session.h index 0a6fb080..d3e5787c 100644 --- a/include/libssh/session.h +++ b/include/libssh/session.h @@ -223,7 +223,7 @@ struct ssh_session_struct { char *agent_socket; 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 e6264101..a2fdf31a 100644 --- a/src/misc.c +++ b/src/misc.c @@ -1237,14 +1237,13 @@ char *ssh_path_expand_escape(ssh_session session, const char *s) } 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: