diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 1999-12-01 13:59:16 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 1999-12-01 13:59:16 +0000 |
commit | 32aebd23ed26ff522d1fec387f22a813f54a07b7 (patch) | |
tree | 228452b8ae54a8aa472ab14faa7a8ec69b4098be | |
parent | 50ca5e3de65fc38457e155a3e6534eee24fa31d1 (diff) |
ports are u_short
-rw-r--r-- | usr.bin/ssh/channels.c | 24 | ||||
-rw-r--r-- | usr.bin/ssh/readconf.c | 19 | ||||
-rw-r--r-- | usr.bin/ssh/readconf.h | 16 | ||||
-rw-r--r-- | usr.bin/ssh/ssh.c | 16 | ||||
-rw-r--r-- | usr.bin/ssh/ssh.h | 12 | ||||
-rw-r--r-- | usr.bin/ssh/sshconnect.c | 8 |
6 files changed, 44 insertions, 51 deletions
diff --git a/usr.bin/ssh/channels.c b/usr.bin/ssh/channels.c index 81d0113e9e4..7805eda0d9a 100644 --- a/usr.bin/ssh/channels.c +++ b/usr.bin/ssh/channels.c @@ -16,7 +16,7 @@ */ #include "includes.h" -RCSID("$Id: channels.c,v 1.30 1999/11/25 09:10:33 deraadt Exp $"); +RCSID("$Id: channels.c,v 1.31 1999/12/01 13:59:15 markus Exp $"); #include "ssh.h" #include "packet.h" @@ -82,7 +82,7 @@ unsigned int x11_fake_data_len; */ typedef struct { char *host; /* Host name. */ - int port; /* Port number. */ + u_short port; /* Port number. */ } ForwardPermission; /* List of all permitted host/port pairs to connect. */ @@ -876,8 +876,8 @@ channel_open_message() */ void -channel_request_local_forwarding(int port, const char *host, - int host_port) +channel_request_local_forwarding(u_short port, const char *host, + u_short host_port) { int ch, sock, on = 1; struct sockaddr_in sin; @@ -932,8 +932,8 @@ channel_request_local_forwarding(int port, const char *host, */ void -channel_request_remote_forwarding(int port, const char *host, - int remote_port) +channel_request_remote_forwarding(u_short port, const char *host, + u_short remote_port) { int payload_len; /* Record locally that connection to this host/port is permitted. */ @@ -968,7 +968,7 @@ channel_request_remote_forwarding(int port, const char *host, void channel_input_port_forward_request(int is_root) { - int port, host_port; + u_short port, host_port; char *hostname; /* Get arguments from the packet. */ @@ -976,10 +976,6 @@ channel_input_port_forward_request(int is_root) hostname = packet_get_string(NULL); host_port = packet_get_int(); - /* Port numbers are 16 bit quantities. */ - if ((port & 0xffff) != port) - packet_disconnect("Requested forwarding of nonexistent port %d.", port); - /* * Check that an unprivileged user is not trying to forward a * privileged port. @@ -1004,7 +1000,8 @@ channel_input_port_forward_request(int is_root) void channel_input_port_open(int payload_len) { - int remote_channel, sock, newch, host_port, i; + int remote_channel, sock, newch, i; + u_short host_port; struct sockaddr_in sin; char *host, *originator_string; struct hostent *hp; @@ -1122,7 +1119,8 @@ char * x11_create_display_inet(int screen_number) { extern ServerOptions options; - int display_number, port, sock; + int display_number, sock; + u_short port; struct sockaddr_in sin; char buf[512]; char hostname[MAXHOSTNAMELEN]; diff --git a/usr.bin/ssh/readconf.c b/usr.bin/ssh/readconf.c index d5a34042f24..32afcdd54d7 100644 --- a/usr.bin/ssh/readconf.c +++ b/usr.bin/ssh/readconf.c @@ -14,7 +14,7 @@ */ #include "includes.h" -RCSID("$Id: readconf.c,v 1.21 1999/11/24 20:24:09 markus Exp $"); +RCSID("$Id: readconf.c,v 1.22 1999/12/01 13:59:15 markus Exp $"); #include "ssh.h" #include "cipher.h" @@ -164,13 +164,11 @@ static struct { */ void -add_local_forward(Options *options, int port, const char *host, - int host_port) +add_local_forward(Options *options, u_short port, const char *host, + u_short host_port) { Forward *fwd; extern uid_t original_real_uid; - if ((port & 0xffff) != port) - fatal("Requested forwarding of nonexistent port %d.", port); if (port < IPPORT_RESERVED && original_real_uid != 0) fatal("Privileged ports can only be forwarded by root.\n"); if (options->num_local_forwards >= SSH_MAX_FORWARDS_PER_DIRECTION) @@ -187,8 +185,8 @@ add_local_forward(Options *options, int port, const char *host, */ void -add_remote_forward(Options *options, int port, const char *host, - int host_port) +add_remote_forward(Options *options, u_short port, const char *host, + u_short host_port) { Forward *fwd; if (options->num_remote_forwards >= SSH_MAX_FORWARDS_PER_DIRECTION) @@ -230,7 +228,8 @@ process_config_line(Options *options, const char *host, int *activep) { char buf[256], *cp, *string, **charptr, *cp2; - int opcode, *intptr, value, fwd_port, fwd_host_port; + int opcode, *intptr, value; + u_short fwd_port, fwd_host_port; /* Skip leading whitespace. */ cp = line + strspn(line, WHITESPACE); @@ -467,7 +466,7 @@ parse_int: if (!cp) fatal("%.200s line %d: Missing second argument.", filename, linenum); - if (sscanf(cp, "%255[^:]:%d", buf, &fwd_host_port) != 2) + if (sscanf(cp, "%255[^:]:%hu", buf, &fwd_host_port) != 2) fatal("%.200s line %d: Badly formatted host:port.", filename, linenum); if (*activep) @@ -486,7 +485,7 @@ parse_int: if (!cp) fatal("%.200s line %d: Missing second argument.", filename, linenum); - if (sscanf(cp, "%255[^:]:%d", buf, &fwd_host_port) != 2) + if (sscanf(cp, "%255[^:]:%hu", buf, &fwd_host_port) != 2) fatal("%.200s line %d: Badly formatted host:port.", filename, linenum); if (*activep) diff --git a/usr.bin/ssh/readconf.h b/usr.bin/ssh/readconf.h index 70baaee6675..1d22002fa3f 100644 --- a/usr.bin/ssh/readconf.h +++ b/usr.bin/ssh/readconf.h @@ -13,7 +13,7 @@ * */ -/* RCSID("$Id: readconf.h,v 1.12 1999/11/24 19:53:49 markus Exp $"); */ +/* RCSID("$Id: readconf.h,v 1.13 1999/12/01 13:59:15 markus Exp $"); */ #ifndef READCONF_H #define READCONF_H @@ -21,9 +21,9 @@ /* Data structure for representing a forwarding request. */ typedef struct { - int port; /* Port to forward. */ - char *host; /* Host to connect. */ - int host_port; /* Port to connect on host. */ + u_short port; /* Port to forward. */ + char *host; /* Host to connect. */ + u_short host_port; /* Port to connect on host. */ } Forward; /* Data structure for representing option data. */ @@ -123,15 +123,15 @@ read_config_file(const char *filename, const char *host, * error. */ void -add_local_forward(Options * options, int port, const char *host, - int host_port); +add_local_forward(Options * options, u_short port, const char *host, + u_short host_port); /* * Adds a remote TCP/IP port forward to options. Never returns if there is * an error. */ void -add_remote_forward(Options * options, int port, const char *host, - int host_port); +add_remote_forward(Options * options, u_short port, const char *host, + u_short host_port); #endif /* READCONF_H */ diff --git a/usr.bin/ssh/ssh.c b/usr.bin/ssh/ssh.c index c36eb04f92e..0d12676739b 100644 --- a/usr.bin/ssh/ssh.c +++ b/usr.bin/ssh/ssh.c @@ -11,7 +11,7 @@ */ #include "includes.h" -RCSID("$Id: ssh.c,v 1.34 1999/11/24 20:15:35 markus Exp $"); +RCSID("$Id: ssh.c,v 1.35 1999/12/01 13:59:15 markus Exp $"); #include "xmalloc.h" #include "ssh.h" @@ -156,8 +156,8 @@ rsh_connect(char *host, char *user, Buffer * command) int main(int ac, char **av) { - int i, opt, optind, type, exit_status, ok, fwd_port, fwd_host_port, - authfd; + int i, opt, optind, type, exit_status, ok, authfd; + u_short fwd_port, fwd_host_port; char *optarg, *cp, buf[256]; Buffer command; struct winsize ws; @@ -334,10 +334,6 @@ main(int ac, char **av) case 'p': options.port = atoi(optarg); - if (options.port < 1 || options.port > 65535) { - fprintf(stderr, "Bad port %s.\n", optarg); - exit(1); - } break; case 'l': @@ -345,7 +341,7 @@ main(int ac, char **av) break; case 'R': - if (sscanf(optarg, "%d:%255[^:]:%d", &fwd_port, buf, + if (sscanf(optarg, "%hu:%255[^:]:%hu", &fwd_port, buf, &fwd_host_port) != 3) { fprintf(stderr, "Bad forwarding specification '%s'.\n", optarg); usage(); @@ -355,7 +351,7 @@ main(int ac, char **av) break; case 'L': - if (sscanf(optarg, "%d:%255[^:]:%d", &fwd_port, buf, + if (sscanf(optarg, "%hu:%255[^:]:%hu", &fwd_port, buf, &fwd_host_port) != 3) { fprintf(stderr, "Bad forwarding specification '%s'.\n", optarg); usage(); @@ -557,7 +553,7 @@ main(int ac, char **av) /* Check if the connection failed, and try "rsh" if appropriate. */ if (!ok) { if (options.port != 0) - log("Secure connection to %.100s on port %d refused%.100s.", + log("Secure connection to %.100s on port %hu refused%.100s.", host, options.port, options.fallback_to_rsh ? "; reverting to insecure method" : ""); else diff --git a/usr.bin/ssh/ssh.h b/usr.bin/ssh/ssh.h index 5f5b351728f..421be61e0fa 100644 --- a/usr.bin/ssh/ssh.h +++ b/usr.bin/ssh/ssh.h @@ -13,7 +13,7 @@ * */ -/* RCSID("$Id: ssh.h,v 1.26 1999/11/24 19:53:52 markus Exp $"); */ +/* RCSID("$Id: ssh.h,v 1.27 1999/12/01 13:59:15 markus Exp $"); */ #ifndef SSH_H #define SSH_H @@ -275,7 +275,7 @@ void record_logout(int pid, const char *ttyname); */ int ssh_connect(const char *host, struct sockaddr_in * hostaddr, - int port, int connection_attempts, + u_short port, int connection_attempts, int anonymous, uid_t original_real_uid, const char *proxy_command); @@ -560,8 +560,8 @@ char *channel_open_message(void); * error. */ void -channel_request_local_forwarding(int port, const char *host, - int remote_port); +channel_request_local_forwarding(u_short port, const char *host, + u_short remote_port); /* * Initiate forwarding of connections to port "port" on remote host through @@ -570,8 +570,8 @@ channel_request_local_forwarding(int port, const char *host, * permitted. */ void -channel_request_remote_forwarding(int port, const char *host, - int remote_port); +channel_request_remote_forwarding(u_short port, const char *host, + u_short remote_port); /* * Permits opening to any host/port in SSH_MSG_PORT_OPEN. This is usually diff --git a/usr.bin/ssh/sshconnect.c b/usr.bin/ssh/sshconnect.c index c3ef1365043..705706006ad 100644 --- a/usr.bin/ssh/sshconnect.c +++ b/usr.bin/ssh/sshconnect.c @@ -8,7 +8,7 @@ */ #include "includes.h" -RCSID("$Id: sshconnect.c,v 1.40 1999/11/24 19:53:53 markus Exp $"); +RCSID("$Id: sshconnect.c,v 1.41 1999/12/01 13:59:15 markus Exp $"); #include <ssl/bn.h> #include "xmalloc.h" @@ -32,7 +32,7 @@ unsigned char session_id[16]; * Connect to the given ssh server using a proxy command. */ int -ssh_proxy_connect(const char *host, int port, uid_t original_real_uid, +ssh_proxy_connect(const char *host, u_short port, uid_t original_real_uid, const char *proxy_command) { Buffer command; @@ -43,7 +43,7 @@ ssh_proxy_connect(const char *host, int port, uid_t original_real_uid, char portstring[100]; /* Convert the port number into a string. */ - snprintf(portstring, sizeof portstring, "%d", port); + snprintf(portstring, sizeof portstring, "%hu", port); /* Build the final command string in the buffer by making the appropriate substitutions to the given proxy command. */ @@ -171,7 +171,7 @@ ssh_create_socket(uid_t original_real_uid, int privileged) */ int ssh_connect(const char *host, struct sockaddr_in * hostaddr, - int port, int connection_attempts, + u_short port, int connection_attempts, int anonymous, uid_t original_real_uid, const char *proxy_command) { |