summaryrefslogtreecommitdiff
path: root/servconf.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2009-01-28 16:31:22 +1100
committerDamien Miller <djm@mindrot.org>2009-01-28 16:31:22 +1100
commit3dc71ad8653bab5591fc75bb1d3e6aa8fb9360df (patch)
treec41a8152c222b8bebb63d9d9185e8a160b71a5a0 /servconf.c
parent9576ac4afc7124415183dd9fe73d410165dbfe82 (diff)
- djm@cvs.openbsd.org 2009/01/22 10:02:34
[clientloop.c misc.c readconf.c readconf.h servconf.c servconf.h] [serverloop.c ssh-keyscan.c ssh.c sshd.c] make a2port() return -1 when it encounters an invalid port number rather than 0, which it will now treat as valid (needed for future work) adjust current consumers of a2port() to check its return value is <= 0, which in turn required some things to be converted from u_short => int make use of int vs. u_short consistent in some other places too feedback & ok markus@
Diffstat (limited to 'servconf.c')
-rw-r--r--servconf.c20
1 files changed, 10 insertions, 10 deletions
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
45static void add_listen_addr(ServerOptions *, char *, u_short); 45static void add_listen_addr(ServerOptions *, char *, int);
46static void add_one_listen_addr(ServerOptions *, char *, u_short); 46static void add_one_listen_addr(ServerOptions *, char *, int);
47 47
48/* Use of privilege separation or not */ 48/* Use of privilege separation or not */
49extern int use_privsep; 49extern int use_privsep;
@@ -460,7 +460,7 @@ parse_token(const char *cp, const char *filename,
460} 460}
461 461
462static void 462static void
463add_listen_addr(ServerOptions *options, char *addr, u_short port) 463add_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
478static void 478static void
479add_one_listen_addr(ServerOptions *options, char *addr, u_short port) 479add_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)