diff options
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | clientloop.c | 10 | ||||
-rw-r--r-- | misc.c | 22 | ||||
-rw-r--r-- | readconf.c | 6 | ||||
-rw-r--r-- | readconf.h | 6 | ||||
-rw-r--r-- | servconf.c | 20 | ||||
-rw-r--r-- | servconf.h | 8 | ||||
-rw-r--r-- | serverloop.c | 4 | ||||
-rw-r--r-- | ssh-keyscan.c | 4 | ||||
-rw-r--r-- | ssh.c | 4 | ||||
-rw-r--r-- | sshd.c | 4 |
11 files changed, 52 insertions, 47 deletions
@@ -61,6 +61,15 @@ | |||
61 | [channels.c] | 61 | [channels.c] |
62 | oops! I committed the wrong version of the Channel->path diff, | 62 | oops! I committed the wrong version of the Channel->path diff, |
63 | it was missing some tweaks suggested by stevesk@ | 63 | it was missing some tweaks suggested by stevesk@ |
64 | - djm@cvs.openbsd.org 2009/01/22 10:02:34 | ||
65 | [clientloop.c misc.c readconf.c readconf.h servconf.c servconf.h] | ||
66 | [serverloop.c ssh-keyscan.c ssh.c sshd.c] | ||
67 | make a2port() return -1 when it encounters an invalid port number | ||
68 | rather than 0, which it will now treat as valid (needed for future work) | ||
69 | adjust current consumers of a2port() to check its return value is <= 0, | ||
70 | which in turn required some things to be converted from u_short => int | ||
71 | make use of int vs. u_short consistent in some other places too | ||
72 | feedback & ok markus@ | ||
64 | 73 | ||
65 | 20090107 | 74 | 20090107 |
66 | - (djm) [uidswap.c] bz#1412: Support >16 supplemental groups in OS X. | 75 | - (djm) [uidswap.c] bz#1412: Support >16 supplemental groups in OS X. |
@@ -5070,5 +5079,5 @@ | |||
5070 | OpenServer 6 and add osr5bigcrypt support so when someone migrates | 5079 | OpenServer 6 and add osr5bigcrypt support so when someone migrates |
5071 | passwords between UnixWare and OpenServer they will still work. OK dtucker@ | 5080 | passwords between UnixWare and OpenServer they will still work. OK dtucker@ |
5072 | 5081 | ||
5073 | $Id: ChangeLog,v 1.5174 2009/01/28 05:30:33 djm Exp $ | 5082 | $Id: ChangeLog,v 1.5175 2009/01/28 05:31:22 djm Exp $ |
5074 | 5083 | ||
diff --git a/clientloop.c b/clientloop.c index fdeedc351..1b5badb71 100644 --- a/clientloop.c +++ b/clientloop.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: clientloop.c,v 1.207 2008/12/09 22:37:33 stevesk Exp $ */ | 1 | /* $OpenBSD: clientloop.c,v 1.208 2009/01/22 10:02:34 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -765,7 +765,7 @@ process_cmdline(void) | |||
765 | char *s, *cmd, *cancel_host; | 765 | char *s, *cmd, *cancel_host; |
766 | int delete = 0; | 766 | int delete = 0; |
767 | int local = 0, remote = 0, dynamic = 0; | 767 | int local = 0, remote = 0, dynamic = 0; |
768 | u_short cancel_port; | 768 | int cancel_port; |
769 | Forward fwd; | 769 | Forward fwd; |
770 | 770 | ||
771 | bzero(&fwd, sizeof(fwd)); | 771 | bzero(&fwd, sizeof(fwd)); |
@@ -843,7 +843,7 @@ process_cmdline(void) | |||
843 | cancel_port = a2port(cancel_host); | 843 | cancel_port = a2port(cancel_host); |
844 | cancel_host = NULL; | 844 | cancel_host = NULL; |
845 | } | 845 | } |
846 | if (cancel_port == 0) { | 846 | if (cancel_port <= 0) { |
847 | logit("Bad forwarding close port"); | 847 | logit("Bad forwarding close port"); |
848 | goto out; | 848 | goto out; |
849 | } | 849 | } |
@@ -1638,7 +1638,7 @@ client_request_forwarded_tcpip(const char *request_type, int rchan) | |||
1638 | { | 1638 | { |
1639 | Channel *c = NULL; | 1639 | Channel *c = NULL; |
1640 | char *listen_address, *originator_address; | 1640 | char *listen_address, *originator_address; |
1641 | int listen_port, originator_port; | 1641 | u_short listen_port, originator_port; |
1642 | 1642 | ||
1643 | /* Get rest of the packet */ | 1643 | /* Get rest of the packet */ |
1644 | listen_address = packet_get_string(NULL); | 1644 | listen_address = packet_get_string(NULL); |
@@ -1664,7 +1664,7 @@ client_request_x11(const char *request_type, int rchan) | |||
1664 | { | 1664 | { |
1665 | Channel *c = NULL; | 1665 | Channel *c = NULL; |
1666 | char *originator; | 1666 | char *originator; |
1667 | int originator_port; | 1667 | u_short originator_port; |
1668 | int sock; | 1668 | int sock; |
1669 | 1669 | ||
1670 | if (!options.forward_x11) { | 1670 | if (!options.forward_x11) { |
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: misc.c,v 1.69 2008/06/13 01:38:23 dtucker Exp $ */ | 1 | /* $OpenBSD: misc.c,v 1.70 2009/01/22 10:02:34 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2000 Markus Friedl. All rights reserved. | 3 | * Copyright (c) 2000 Markus Friedl. All rights reserved. |
4 | * Copyright (c) 2005,2006 Damien Miller. All rights reserved. | 4 | * Copyright (c) 2005,2006 Damien Miller. All rights reserved. |
@@ -221,23 +221,19 @@ pwcopy(struct passwd *pw) | |||
221 | 221 | ||
222 | /* | 222 | /* |
223 | * Convert ASCII string to TCP/IP port number. | 223 | * Convert ASCII string to TCP/IP port number. |
224 | * Port must be >0 and <=65535. | 224 | * Port must be >=0 and <=65535. |
225 | * Return 0 if invalid. | 225 | * Return -1 if invalid. |
226 | */ | 226 | */ |
227 | int | 227 | int |
228 | a2port(const char *s) | 228 | a2port(const char *s) |
229 | { | 229 | { |
230 | long port; | 230 | long long port; |
231 | char *endp; | 231 | const char *errstr; |
232 | |||
233 | errno = 0; | ||
234 | port = strtol(s, &endp, 0); | ||
235 | if (s == endp || *endp != '\0' || | ||
236 | (errno == ERANGE && (port == LONG_MIN || port == LONG_MAX)) || | ||
237 | port <= 0 || port > 65535) | ||
238 | return 0; | ||
239 | 232 | ||
240 | return port; | 233 | port = strtonum(s, 0, 65535, &errstr); |
234 | if (errstr != NULL) | ||
235 | return -1; | ||
236 | return (int)port; | ||
241 | } | 237 | } |
242 | 238 | ||
243 | int | 239 | int |
diff --git a/readconf.c b/readconf.c index f63a00c47..0a8be1400 100644 --- a/readconf.c +++ b/readconf.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: readconf.c,v 1.174 2009/01/15 17:38:43 stevesk Exp $ */ | 1 | /* $OpenBSD: readconf.c,v 1.175 2009/01/22 10:02:34 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -1279,11 +1279,11 @@ parse_forward(Forward *fwd, const char *fwdspec, int dynamicfwd) | |||
1279 | } else { | 1279 | } else { |
1280 | if (!(i == 3 || i == 4)) | 1280 | if (!(i == 3 || i == 4)) |
1281 | goto fail_free; | 1281 | goto fail_free; |
1282 | if (fwd->connect_port == 0) | 1282 | if (fwd->connect_port <= 0) |
1283 | goto fail_free; | 1283 | goto fail_free; |
1284 | } | 1284 | } |
1285 | 1285 | ||
1286 | if (fwd->listen_port == 0) | 1286 | if (fwd->listen_port <= 0) |
1287 | goto fail_free; | 1287 | goto fail_free; |
1288 | 1288 | ||
1289 | if (fwd->connect_host != NULL && | 1289 | if (fwd->connect_host != NULL && |
diff --git a/readconf.h b/readconf.h index c9e5f6a41..d94d65890 100644 --- a/readconf.h +++ b/readconf.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: readconf.h,v 1.76 2008/11/04 08:22:13 djm Exp $ */ | 1 | /* $OpenBSD: readconf.h,v 1.77 2009/01/22 10:02:34 djm Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
@@ -20,9 +20,9 @@ | |||
20 | 20 | ||
21 | typedef struct { | 21 | typedef struct { |
22 | char *listen_host; /* Host (address) to listen on. */ | 22 | char *listen_host; /* Host (address) to listen on. */ |
23 | u_short listen_port; /* Port to forward. */ | 23 | int listen_port; /* Port to forward. */ |
24 | char *connect_host; /* Host to connect. */ | 24 | char *connect_host; /* Host to connect. */ |
25 | u_short connect_port; /* Port to connect on connect_host. */ | 25 | int connect_port; /* Port to connect on connect_host. */ |
26 | } Forward; | 26 | } Forward; |
27 | /* Data structure for representing option data. */ | 27 | /* Data structure for representing option data. */ |
28 | 28 | ||
diff --git a/servconf.c b/servconf.c index 7d8851860..e7fc2a781 100644 --- a/servconf.c +++ b/servconf.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: servconf.c,v 1.193 2008/12/09 03:20:42 stevesk Exp $ */ | 1 | /* $OpenBSD: servconf.c,v 1.194 2009/01/22 10:02:34 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 3 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
4 | * All rights reserved | 4 | * All rights reserved |
@@ -42,8 +42,8 @@ | |||
42 | #include "channels.h" | 42 | #include "channels.h" |
43 | #include "groupaccess.h" | 43 | #include "groupaccess.h" |
44 | 44 | ||
45 | static void add_listen_addr(ServerOptions *, char *, u_short); | 45 | static void add_listen_addr(ServerOptions *, char *, int); |
46 | static void add_one_listen_addr(ServerOptions *, char *, u_short); | 46 | static void add_one_listen_addr(ServerOptions *, char *, int); |
47 | 47 | ||
48 | /* Use of privilege separation or not */ | 48 | /* Use of privilege separation or not */ |
49 | extern int use_privsep; | 49 | extern int use_privsep; |
@@ -460,7 +460,7 @@ parse_token(const char *cp, const char *filename, | |||
460 | } | 460 | } |
461 | 461 | ||
462 | static void | 462 | static void |
463 | add_listen_addr(ServerOptions *options, char *addr, u_short port) | 463 | add_listen_addr(ServerOptions *options, char *addr, int port) |
464 | { | 464 | { |
465 | u_int i; | 465 | u_int i; |
466 | 466 | ||
@@ -476,7 +476,7 @@ add_listen_addr(ServerOptions *options, char *addr, u_short port) | |||
476 | } | 476 | } |
477 | 477 | ||
478 | static void | 478 | static void |
479 | add_one_listen_addr(ServerOptions *options, char *addr, u_short port) | 479 | add_one_listen_addr(ServerOptions *options, char *addr, int port) |
480 | { | 480 | { |
481 | struct addrinfo hints, *ai, *aitop; | 481 | struct addrinfo hints, *ai, *aitop; |
482 | char strport[NI_MAXSERV]; | 482 | char strport[NI_MAXSERV]; |
@@ -486,7 +486,7 @@ add_one_listen_addr(ServerOptions *options, char *addr, u_short port) | |||
486 | hints.ai_family = options->address_family; | 486 | hints.ai_family = options->address_family; |
487 | hints.ai_socktype = SOCK_STREAM; | 487 | hints.ai_socktype = SOCK_STREAM; |
488 | hints.ai_flags = (addr == NULL) ? AI_PASSIVE : 0; | 488 | hints.ai_flags = (addr == NULL) ? AI_PASSIVE : 0; |
489 | snprintf(strport, sizeof strport, "%u", port); | 489 | snprintf(strport, sizeof strport, "%d", port); |
490 | if ((gaierr = getaddrinfo(addr, strport, &hints, &aitop)) != 0) | 490 | if ((gaierr = getaddrinfo(addr, strport, &hints, &aitop)) != 0) |
491 | fatal("bad addr or host: %s (%s)", | 491 | fatal("bad addr or host: %s (%s)", |
492 | addr ? addr : "<NULL>", | 492 | addr ? addr : "<NULL>", |
@@ -642,7 +642,7 @@ process_server_config_line(ServerOptions *options, char *line, | |||
642 | SyslogFacility *log_facility_ptr; | 642 | SyslogFacility *log_facility_ptr; |
643 | LogLevel *log_level_ptr; | 643 | LogLevel *log_level_ptr; |
644 | ServerOpCodes opcode; | 644 | ServerOpCodes opcode; |
645 | u_short port; | 645 | int port; |
646 | u_int i, flags = 0; | 646 | u_int i, flags = 0; |
647 | size_t len; | 647 | size_t len; |
648 | 648 | ||
@@ -699,7 +699,7 @@ process_server_config_line(ServerOptions *options, char *line, | |||
699 | fatal("%s line %d: missing port number.", | 699 | fatal("%s line %d: missing port number.", |
700 | filename, linenum); | 700 | filename, linenum); |
701 | options->ports[options->num_ports++] = a2port(arg); | 701 | options->ports[options->num_ports++] = a2port(arg); |
702 | if (options->ports[options->num_ports-1] == 0) | 702 | if (options->ports[options->num_ports-1] <= 0) |
703 | fatal("%s line %d: Badly formatted port number.", | 703 | fatal("%s line %d: Badly formatted port number.", |
704 | filename, linenum); | 704 | filename, linenum); |
705 | break; | 705 | break; |
@@ -752,7 +752,7 @@ process_server_config_line(ServerOptions *options, char *line, | |||
752 | p = cleanhostname(p); | 752 | p = cleanhostname(p); |
753 | if (arg == NULL) | 753 | if (arg == NULL) |
754 | port = 0; | 754 | port = 0; |
755 | else if ((port = a2port(arg)) == 0) | 755 | else if ((port = a2port(arg)) <= 0) |
756 | fatal("%s line %d: bad port number", filename, linenum); | 756 | fatal("%s line %d: bad port number", filename, linenum); |
757 | 757 | ||
758 | add_listen_addr(options, p, port); | 758 | add_listen_addr(options, p, port); |
@@ -1265,7 +1265,7 @@ process_server_config_line(ServerOptions *options, char *line, | |||
1265 | fatal("%s line %d: missing host in PermitOpen", | 1265 | fatal("%s line %d: missing host in PermitOpen", |
1266 | filename, linenum); | 1266 | filename, linenum); |
1267 | p = cleanhostname(p); | 1267 | p = cleanhostname(p); |
1268 | if (arg == NULL || (port = a2port(arg)) == 0) | 1268 | if (arg == NULL || (port = a2port(arg)) <= 0) |
1269 | fatal("%s line %d: bad port number in " | 1269 | fatal("%s line %d: bad port number in " |
1270 | "PermitOpen", filename, linenum); | 1270 | "PermitOpen", filename, linenum); |
1271 | if (*activep && n == -1) | 1271 | if (*activep && n == -1) |
diff --git a/servconf.h b/servconf.h index 1d4c3a01a..b3ac7da4b 100644 --- a/servconf.h +++ b/servconf.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: servconf.h,v 1.86 2008/11/04 08:22:13 djm Exp $ */ | 1 | /* $OpenBSD: servconf.h,v 1.87 2009/01/22 10:02:34 djm Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
@@ -41,9 +41,9 @@ | |||
41 | #define INTERNAL_SFTP_NAME "internal-sftp" | 41 | #define INTERNAL_SFTP_NAME "internal-sftp" |
42 | 42 | ||
43 | typedef struct { | 43 | typedef struct { |
44 | u_int num_ports; | 44 | u_int num_ports; |
45 | u_int ports_from_cmdline; | 45 | u_int ports_from_cmdline; |
46 | u_short ports[MAX_PORTS]; /* Port number to listen on. */ | 46 | int ports[MAX_PORTS]; /* Port number to listen on. */ |
47 | char *listen_addr; /* Address on which the server listens. */ | 47 | char *listen_addr; /* Address on which the server listens. */ |
48 | struct addrinfo *listen_addrs; /* Addresses on which the server listens. */ | 48 | struct addrinfo *listen_addrs; /* Addresses on which the server listens. */ |
49 | int address_family; /* Address family used by the server. */ | 49 | int address_family; /* Address family used by the server. */ |
diff --git a/serverloop.c b/serverloop.c index 6a3ae1665..931779e30 100644 --- a/serverloop.c +++ b/serverloop.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: serverloop.c,v 1.154 2008/12/02 19:08:59 markus Exp $ */ | 1 | /* $OpenBSD: serverloop.c,v 1.155 2009/01/22 10:02:34 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -942,7 +942,7 @@ server_request_direct_tcpip(void) | |||
942 | { | 942 | { |
943 | Channel *c; | 943 | Channel *c; |
944 | char *target, *originator; | 944 | char *target, *originator; |
945 | int target_port, originator_port; | 945 | u_short target_port, originator_port; |
946 | 946 | ||
947 | target = packet_get_string(NULL); | 947 | target = packet_get_string(NULL); |
948 | target_port = packet_get_int(); | 948 | target_port = packet_get_int(); |
diff --git a/ssh-keyscan.c b/ssh-keyscan.c index c6ec3507e..9a91be499 100644 --- a/ssh-keyscan.c +++ b/ssh-keyscan.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh-keyscan.c,v 1.77 2008/11/01 11:14:36 sobrado Exp $ */ | 1 | /* $OpenBSD: ssh-keyscan.c,v 1.78 2009/01/22 10:02:34 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>. | 3 | * Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>. |
4 | * | 4 | * |
@@ -748,7 +748,7 @@ main(int argc, char **argv) | |||
748 | break; | 748 | break; |
749 | case 'p': | 749 | case 'p': |
750 | ssh_port = a2port(optarg); | 750 | ssh_port = a2port(optarg); |
751 | if (ssh_port == 0) { | 751 | if (ssh_port <= 0) { |
752 | fprintf(stderr, "Bad port '%s'\n", optarg); | 752 | fprintf(stderr, "Bad port '%s'\n", optarg); |
753 | exit(1); | 753 | exit(1); |
754 | } | 754 | } |
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh.c,v 1.322 2008/11/01 17:40:33 stevesk Exp $ */ | 1 | /* $OpenBSD: ssh.c,v 1.323 2009/01/22 10:02:34 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -443,7 +443,7 @@ main(int ac, char **av) | |||
443 | break; | 443 | break; |
444 | case 'p': | 444 | case 'p': |
445 | options.port = a2port(optarg); | 445 | options.port = a2port(optarg); |
446 | if (options.port == 0) { | 446 | if (options.port <= 0) { |
447 | fprintf(stderr, "Bad port '%s'\n", optarg); | 447 | fprintf(stderr, "Bad port '%s'\n", optarg); |
448 | exit(255); | 448 | exit(255); |
449 | } | 449 | } |
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sshd.c,v 1.365 2008/10/30 19:31:16 stevesk Exp $ */ | 1 | /* $OpenBSD: sshd.c,v 1.366 2009/01/22 10:02:34 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -1333,7 +1333,7 @@ main(int ac, char **av) | |||
1333 | exit(1); | 1333 | exit(1); |
1334 | } | 1334 | } |
1335 | options.ports[options.num_ports++] = a2port(optarg); | 1335 | options.ports[options.num_ports++] = a2port(optarg); |
1336 | if (options.ports[options.num_ports-1] == 0) { | 1336 | if (options.ports[options.num_ports-1] <= 0) { |
1337 | fprintf(stderr, "Bad port number.\n"); | 1337 | fprintf(stderr, "Bad port number.\n"); |
1338 | exit(1); | 1338 | exit(1); |
1339 | } | 1339 | } |