Skip to content

Commit 683d0ab

Browse files
committed
upstream: Make MaxStartups and PerSourceNetBlockSize first-match-wins
as advertised. bz3859 reported by jan.v.hofmann; ok dtucker OpenBSD-Commit-ID: 08f7786f1b3b4a05a106cdbd2dc5f1f2d8299447
1 parent a9a3f02 commit 683d0ab

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

servconf.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: servconf.c,v 1.431 2025/08/29 03:50:38 djm Exp $ */
1+
/* $OpenBSD: servconf.c,v 1.432 2025/09/01 23:53:16 djm Exp $ */
22
/*
33
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
44
* All rights reserved
@@ -1315,7 +1315,7 @@ process_server_config_line_depth(ServerOptions *options, char *line,
13151315
struct include_list *includes)
13161316
{
13171317
char *str, ***chararrayptr, **charptr, *arg, *arg2, *p, *keyword;
1318-
int cmdline = 0, *intptr, value, value2, n, port, oactive, r;
1318+
int cmdline = 0, *intptr, value, value2, value3, n, port, oactive, r;
13191319
int ca_only = 0, found = 0;
13201320
SyslogFacility *log_facility_ptr;
13211321
LogLevel *log_level_ptr;
@@ -2003,25 +2003,27 @@ process_server_config_line_depth(ServerOptions *options, char *line,
20032003
if (!arg || *arg == '\0')
20042004
fatal("%s line %d: %s missing argument.",
20052005
filename, linenum, keyword);
2006+
/* begin:rate:max */
20062007
if ((n = sscanf(arg, "%d:%d:%d",
2007-
&options->max_startups_begin,
2008-
&options->max_startups_rate,
2009-
&options->max_startups)) == 3) {
2010-
if (options->max_startups_begin >
2011-
options->max_startups ||
2012-
options->max_startups_rate > 100 ||
2013-
options->max_startups_rate < 1)
2008+
&value, &value2, &value3)) == 3) {
2009+
if (value > value3 || value2 > 100 || value2 < 1)
20142010
fatal("%s line %d: Invalid %s spec.",
20152011
filename, linenum, keyword);
2016-
} else if (n != 1)
2012+
} else if (n == 1) {
2013+
value3 = value;
2014+
value = value2 = -1;
2015+
} else {
20172016
fatal("%s line %d: Invalid %s spec.",
20182017
filename, linenum, keyword);
2019-
else
2020-
options->max_startups = options->max_startups_begin;
2021-
if (options->max_startups <= 0 ||
2022-
options->max_startups_begin <= 0)
2018+
}
2019+
if (value3 <= 0 || value <= 0)
20232020
fatal("%s line %d: Invalid %s spec.",
20242021
filename, linenum, keyword);
2022+
if (*activep && options->max_startups == -1) {
2023+
options->max_startups_begin = value;
2024+
options->max_startups_rate = value2;
2025+
options->max_startups = value3;
2026+
}
20252027
break;
20262028

20272029
case sPerSourceNetBlockSize:
@@ -2041,7 +2043,7 @@ process_server_config_line_depth(ServerOptions *options, char *line,
20412043
if (n != 1 && n != 2)
20422044
fatal("%s line %d: Invalid %s spec.",
20432045
filename, linenum, keyword);
2044-
if (*activep) {
2046+
if (*activep && options->per_source_masklen_ipv4 == -1) {
20452047
options->per_source_masklen_ipv4 = value;
20462048
options->per_source_masklen_ipv6 = value2;
20472049
}

0 commit comments

Comments
 (0)