Skip to content

Commit 8d1c300

Browse files
committed
sync with mod_md github
* src/md_util.h: Include <apr_cstr.h> for APR 1.6+, or else define apr_cstr_casecmp to apr_natcasecmp as previously. by notroj git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1928839 13f79535-47bb-0310-9956-ffa450edef68
1 parent 3adf329 commit 8d1c300

File tree

12 files changed

+65
-54
lines changed

12 files changed

+65
-54
lines changed

modules/md/md_acme.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static apr_status_t problem_status_get(const char *type) {
8181
}
8282

8383
for(i = 0; i < (sizeof(Problems)/sizeof(Problems[0])); ++i) {
84-
if (!apr_strnatcasecmp(type, Problems[i].type)) {
84+
if (!apr_cstr_casecmp(type, Problems[i].type)) {
8585
return Problems[i].rv;
8686
}
8787
}
@@ -100,7 +100,7 @@ int md_acme_problem_is_input_related(const char *problem) {
100100
}
101101

102102
for(i = 0; i < (sizeof(Problems)/sizeof(Problems[0])); ++i) {
103-
if (!apr_strnatcasecmp(problem, Problems[i].type)) {
103+
if (!apr_cstr_casecmp(problem, Problems[i].type)) {
104104
return Problems[i].input_related;
105105
}
106106
}

modules/md/md_acme_authz.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ static apr_status_t find_type(void *baton, size_t index, md_json_t *json)
594594
cha_find_ctx *ctx = baton;
595595

596596
const char *ctype = md_json_gets(json, MD_KEY_TYPE, NULL);
597-
if (ctype && !apr_strnatcasecmp(ctx->type, ctype)) {
597+
if (ctype && !apr_cstr_casecmp(ctx->type, ctype)) {
598598
ctx->accepted = cha_from_json(ctx->p, index, json);
599599
return 0;
600600
}
@@ -644,7 +644,7 @@ apr_status_t md_acme_authz_respond(md_acme_authz_t *authz, md_acme_t *acme, md_s
644644

645645
if (fctx.accepted) {
646646
for (j = 0; j < (int)CHA_TYPES_LEN; ++j) {
647-
if (!apr_strnatcasecmp(CHA_TYPES[j].name, fctx.accepted->type)) {
647+
if (!apr_cstr_casecmp(CHA_TYPES[j].name, fctx.accepted->type)) {
648648
md_result_activity_printf(result, "Setting up challenge '%s' for domain %s",
649649
fctx.accepted->type, authz->domain);
650650
rv = CHA_TYPES[j].setup(fctx.accepted, authz, acme, store, key_specs,
@@ -702,7 +702,7 @@ apr_status_t md_acme_authz_teardown(struct md_store_t *store, const char *token,
702702
domain = strchr(challenge, ':');
703703
*domain = '\0'; domain++;
704704
for (i = 0; i < (int)CHA_TYPES_LEN; ++i) {
705-
if (!apr_strnatcasecmp(CHA_TYPES[i].name, challenge)) {
705+
if (!apr_cstr_casecmp(CHA_TYPES[i].name, challenge)) {
706706
if (CHA_TYPES[i].teardown) {
707707
return CHA_TYPES[i].teardown(store, domain, md, env, p);
708708
}

modules/md/md_acmev2_drive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static apr_status_t ad_setup_order(md_proto_driver_t *d, md_result_t *result, in
109109
int i;
110110
for (i = 0; !profile && i < ad->acme->api.v2.profiles->nelts; ++i) {
111111
const char *s = APR_ARRAY_IDX(ad->acme->api.v2.profiles, i, const char*);
112-
if (!apr_strnatcasecmp(s, ad->profile))
112+
if (!apr_cstr_casecmp(s, ad->profile))
113113
profile = s;
114114
}
115115
}

modules/md/md_core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ const char *md_get_ca_name_from_url(apr_pool_t *p, const char *url)
430430
unsigned int i;
431431

432432
for (i = 0; i < sizeof(KNOWN_CAs)/sizeof(KNOWN_CAs[0]); ++i) {
433-
if (!apr_strnatcasecmp(KNOWN_CAs[i].url, url)) {
433+
if (!apr_cstr_casecmp(KNOWN_CAs[i].url, url)) {
434434
return KNOWN_CAs[i].name;
435435
}
436436
}
@@ -448,7 +448,7 @@ apr_status_t md_get_ca_url_from_name(const char **purl, apr_pool_t *p, const cha
448448

449449
*purl = NULL;
450450
for (i = 0; i < sizeof(KNOWN_CAs)/sizeof(KNOWN_CAs[0]); ++i) {
451-
if (!apr_strnatcasecmp(KNOWN_CAs[i].name, name)) {
451+
if (!apr_cstr_casecmp(KNOWN_CAs[i].name, name)) {
452452
*purl = KNOWN_CAs[i].url;
453453
goto leave;
454454
}

modules/md/md_crypt.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ int md_pkeys_spec_contains_ec(md_pkeys_spec_t *pks, const char *curve)
338338
for (i = 0; i < pks->specs->nelts; ++i) {
339339
spec = APR_ARRAY_IDX(pks->specs, i, md_pkey_spec_t*);
340340
if (MD_PKEY_TYPE_EC == spec->type
341-
&& !apr_strnatcasecmp(curve, spec->params.ec.curve)) return 1;
341+
&& !apr_cstr_casecmp(curve, spec->params.ec.curve)) return 1;
342342
}
343343
return 0;
344344
}
@@ -428,10 +428,10 @@ md_pkey_spec_t *md_pkey_spec_from_json(struct md_json_t *json, apr_pool_t *p)
428428

429429
if (spec) {
430430
s = md_json_gets(json, MD_KEY_TYPE, NULL);
431-
if (!s || !apr_strnatcasecmp("Default", s)) {
431+
if (!s || !apr_cstr_casecmp("Default", s)) {
432432
spec->type = MD_PKEY_TYPE_DEFAULT;
433433
}
434-
else if (!apr_strnatcasecmp("RSA", s)) {
434+
else if (!apr_cstr_casecmp("RSA", s)) {
435435
spec->type = MD_PKEY_TYPE_RSA;
436436
l = md_json_getl(json, MD_KEY_BITS, NULL);
437437
if (l >= MD_PKEY_RSA_BITS_MIN) {
@@ -441,7 +441,7 @@ md_pkey_spec_t *md_pkey_spec_from_json(struct md_json_t *json, apr_pool_t *p)
441441
spec->params.rsa.bits = MD_PKEY_RSA_BITS_DEF;
442442
}
443443
}
444-
else if (!apr_strnatcasecmp("EC", s)) {
444+
else if (!apr_cstr_casecmp("EC", s)) {
445445
spec->type = MD_PKEY_TYPE_EC;
446446
s = md_json_gets(json, MD_KEY_CURVE, NULL);
447447
if (s) {
@@ -861,26 +861,26 @@ static apr_status_t gen_ec(md_pkey_t **ppkey, apr_pool_t *p, const char *curve)
861861
curve_nid = EC_curve_nist2nid(curve);
862862
/* In case this fails, try some names from other standards, like SECG */
863863
#ifdef NID_secp384r1
864-
if (NID_undef == curve_nid && !apr_strnatcasecmp("secp384r1", curve)) {
864+
if (NID_undef == curve_nid && !apr_cstr_casecmp("secp384r1", curve)) {
865865
curve_nid = NID_secp384r1;
866866
curve = EC_curve_nid2nist(curve_nid);
867867
}
868868
#endif
869869
#ifdef NID_X9_62_prime256v1
870-
if (NID_undef == curve_nid && !apr_strnatcasecmp("secp256r1", curve)) {
870+
if (NID_undef == curve_nid && !apr_cstr_casecmp("secp256r1", curve)) {
871871
curve_nid = NID_X9_62_prime256v1;
872872
curve = EC_curve_nid2nist(curve_nid);
873873
}
874874
#endif
875875
#ifdef NID_X9_62_prime192v1
876-
if (NID_undef == curve_nid && !apr_strnatcasecmp("secp192r1", curve)) {
876+
if (NID_undef == curve_nid && !apr_cstr_casecmp("secp192r1", curve)) {
877877
curve_nid = NID_X9_62_prime192v1;
878878
curve = EC_curve_nid2nist(curve_nid);
879879
}
880880
#endif
881881
#if defined(NID_X25519) && (!defined(LIBRESSL_VERSION_NUMBER) || \
882882
LIBRESSL_VERSION_NUMBER >= 0x3070000fL)
883-
if (NID_undef == curve_nid && !apr_strnatcasecmp("X25519", curve)) {
883+
if (NID_undef == curve_nid && !apr_cstr_casecmp("X25519", curve)) {
884884
curve_nid = NID_X25519;
885885
curve = EC_curve_nid2nist(curve_nid);
886886
}

modules/md/md_curl.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <apr_strings.h>
2323
#include <apr_buckets.h>
2424

25+
#include "md.h"
2526
#include "md_http.h"
2627
#include "md_log.h"
2728
#include "md_util.h"
@@ -275,13 +276,13 @@ static apr_status_t internals_setup(md_http_request_t *req)
275276
internals->response->body = apr_brigade_create(req->pool, req->bucket_alloc);
276277

277278
curl_easy_setopt(curl, CURLOPT_URL, req->url);
278-
if (!apr_strnatcasecmp("GET", req->method)) {
279+
if (!apr_cstr_casecmp("GET", req->method)) {
279280
/* nop */
280281
}
281-
else if (!apr_strnatcasecmp("HEAD", req->method)) {
282+
else if (!apr_cstr_casecmp("HEAD", req->method)) {
282283
curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
283284
}
284-
else if (!apr_strnatcasecmp("POST", req->method)) {
285+
else if (!apr_cstr_casecmp("POST", req->method)) {
285286
curl_easy_setopt(curl, CURLOPT_POST, 1L);
286287
}
287288
else {

modules/md/md_reg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ apr_status_t md_reg_create(md_reg_t **preg, apr_pool_t *p, struct md_store_t *st
111111
reg->can_http = 1;
112112
reg->can_https = 1;
113113
reg->proxy_url = proxy_url? apr_pstrdup(p, proxy_url) : NULL;
114-
reg->ca_file = (ca_file && apr_strnatcasecmp("none", ca_file))?
114+
reg->ca_file = (ca_file && apr_cstr_casecmp("none", ca_file))?
115115
apr_pstrdup(p, ca_file) : NULL;
116116
reg->min_delay = min_delay;
117117
reg->retry_failover = retry_failover;

modules/md/md_store.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ static const char *pk_filename(const char *keyname, const char *base, apr_pool_t
260260
/* We also run on various filesystems with difference upper/lower preserve matching
261261
* rules. Normalize the names we use, since private key specifications are basically
262262
* user input. */
263-
s = (keyname && apr_strnatcasecmp("rsa", keyname))?
263+
s = (keyname && apr_cstr_casecmp("rsa", keyname))?
264264
apr_pstrcat(p, base, ".", keyname, ".pem", NULL)
265265
: apr_pstrcat(p, base, ".pem", NULL);
266266
for (t = s; *t; t++ )

modules/md/md_util.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ int md_array_str_index(const apr_array_header_t *array, const char *s,
256256
for (i = start; i < array->nelts; i++) {
257257
const char *p = APR_ARRAY_IDX(array, i, const char *);
258258
if ((case_sensitive && !strcmp(p, s))
259-
|| (!case_sensitive && !apr_strnatcasecmp(p, s))) {
259+
|| (!case_sensitive && !apr_cstr_casecmp(p, s))) {
260260
return i;
261261
}
262262
}
@@ -278,7 +278,7 @@ int md_array_str_eq(const struct apr_array_header_t *a1,
278278
s1 = APR_ARRAY_IDX(a1, i, const char *);
279279
s2 = APR_ARRAY_IDX(a2, i, const char *);
280280
if ((case_sensitive && strcmp(s1, s2))
281-
|| (!case_sensitive && apr_strnatcasecmp(s1, s2))) {
281+
|| (!case_sensitive && apr_cstr_casecmp(s1, s2))) {
282282
return 0;
283283
}
284284
}
@@ -325,7 +325,7 @@ apr_array_header_t *md_array_str_remove(apr_pool_t *p, apr_array_header_t *src,
325325
const char *s = APR_ARRAY_IDX(src, i, const char *);
326326
if (!exclude
327327
|| (case_sensitive && strcmp(exclude, s))
328-
|| (!case_sensitive && apr_strnatcasecmp(exclude, s))) {
328+
|| (!case_sensitive && apr_cstr_casecmp(exclude, s))) {
329329
APR_ARRAY_PUSH(dest, const char *) = apr_pstrdup(p, s);
330330
}
331331
}
@@ -859,10 +859,10 @@ int md_dns_matches(const char *pattern, const char *domain)
859859
{
860860
const char *s;
861861

862-
if (!apr_strnatcasecmp(pattern, domain)) return 1;
862+
if (!apr_cstr_casecmp(pattern, domain)) return 1;
863863
if (pattern[0] == '*' && pattern[1] == '.') {
864864
s = strchr(domain, '.');
865-
if (s && !apr_strnatcasecmp(pattern+1, s)) return 1;
865+
if (s && !apr_cstr_casecmp(pattern+1, s)) return 1;
866866
}
867867
return 0;
868868
}
@@ -1026,8 +1026,8 @@ apr_status_t md_util_abs_http_uri_check(apr_pool_t *p, const char *uri, const ch
10261026
*perr = "missing uri scheme";
10271027
return APR_EINVAL;
10281028
}
1029-
if (apr_strnatcasecmp("http", uri_parsed.scheme)
1030-
&& apr_strnatcasecmp("https", uri_parsed.scheme)) {
1029+
if (apr_cstr_casecmp("http", uri_parsed.scheme)
1030+
&& apr_cstr_casecmp("https", uri_parsed.scheme)) {
10311031
*perr = "uri scheme must be http or https";
10321032
return APR_EINVAL;
10331033
}
@@ -1509,7 +1509,7 @@ static int find_url(void *baton, const char *key, const char *value)
15091509
{
15101510
find_ctx *outer = baton;
15111511

1512-
if (!apr_strnatcasecmp("link", key)) {
1512+
if (!apr_cstr_casecmp("link", key)) {
15131513
link_ctx ctx;
15141514

15151515
memset(&ctx, 0, sizeof(ctx));

modules/md/md_util.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@
2020
#include <stdio.h>
2121
#include <apr_file_io.h>
2222

23+
#include <apr_version.h>
24+
25+
#if APR_VERSION_AT_LEAST(1,6,0)
26+
#include <apr_cstr.h>
27+
#else
28+
/* Define a (poor) backwards-compatibility entry point for
29+
* apr_cstr_casecmp() from APR 1.6. */
30+
#define apr_cstr_casecmp apr_natcasecmp
31+
#endif
32+
2333
struct apr_array_header_t;
2434
struct apr_table_t;
2535

0 commit comments

Comments
 (0)