diff options
author | djm@openbsd.org <djm@openbsd.org> | 2015-05-04 06:10:48 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2015-05-10 11:38:04 +1000 |
commit | e661a86353e11592c7ed6a847e19a83609f49e77 (patch) | |
tree | 5fe2c206d56dd4296a79e20ca6cfbbb83cb7c40c /match.c | |
parent | 0ef1de742be2ee4b10381193fe90730925b7f027 (diff) |
upstream commit
Remove pattern length argument from match_pattern_list(), we
only ever use it for strlen(pattern).
Prompted by hanno AT hboeck.de pointing an out-of-bound read
error caused by an incorrect pattern length found using AFL
and his own tools.
ok markus@
Diffstat (limited to 'match.c')
-rw-r--r-- | match.c | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: match.c,v 1.29 2013/11/20 20:54:10 deraadt Exp $ */ | 1 | /* $OpenBSD: match.c,v 1.30 2015/05/04 06:10:48 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 |
@@ -115,15 +115,13 @@ match_pattern(const char *s, const char *pattern) | |||
115 | * indicate negation). Returns -1 if negation matches, 1 if there is | 115 | * indicate negation). Returns -1 if negation matches, 1 if there is |
116 | * a positive match, 0 if there is no match at all. | 116 | * a positive match, 0 if there is no match at all. |
117 | */ | 117 | */ |
118 | |||
119 | int | 118 | int |
120 | match_pattern_list(const char *string, const char *pattern, u_int len, | 119 | match_pattern_list(const char *string, const char *pattern, int dolower) |
121 | int dolower) | ||
122 | { | 120 | { |
123 | char sub[1024]; | 121 | char sub[1024]; |
124 | int negated; | 122 | int negated; |
125 | int got_positive; | 123 | int got_positive; |
126 | u_int i, subi; | 124 | u_int i, subi, len = strlen(pattern); |
127 | 125 | ||
128 | got_positive = 0; | 126 | got_positive = 0; |
129 | for (i = 0; i < len;) { | 127 | for (i = 0; i < len;) { |
@@ -177,9 +175,9 @@ match_pattern_list(const char *string, const char *pattern, u_int len, | |||
177 | * a positive match, 0 if there is no match at all. | 175 | * a positive match, 0 if there is no match at all. |
178 | */ | 176 | */ |
179 | int | 177 | int |
180 | match_hostname(const char *host, const char *pattern, u_int len) | 178 | match_hostname(const char *host, const char *pattern) |
181 | { | 179 | { |
182 | return match_pattern_list(host, pattern, len, 1); | 180 | return match_pattern_list(host, pattern, 1); |
183 | } | 181 | } |
184 | 182 | ||
185 | /* | 183 | /* |
@@ -200,7 +198,7 @@ match_host_and_ip(const char *host, const char *ipaddr, | |||
200 | return 0; | 198 | return 0; |
201 | 199 | ||
202 | /* negative hostname match */ | 200 | /* negative hostname match */ |
203 | if ((mhost = match_hostname(host, patterns, strlen(patterns))) == -1) | 201 | if ((mhost = match_hostname(host, patterns)) == -1) |
204 | return 0; | 202 | return 0; |
205 | /* no match at all */ | 203 | /* no match at all */ |
206 | if (mhost == 0 && mip == 0) | 204 | if (mhost == 0 && mip == 0) |