From c05d000c00818a2d42050ddbd76dcb43a95f3b5f Mon Sep 17 00:00:00 2001 From: matcap Date: Tue, 11 May 2021 22:58:34 +0200 Subject: [PATCH] Increased whitelist to 1024 entries. Bound checking on loading. Updated README with new config --- README.md | 2 ++ ngx_http_js_challenge.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c54472b..09f36b6 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ server { js_challenge_html /path/to/body.html; js_challenge_bucket_duration 3600; js_challenge_title "Verifying your browser..."; + js_challenge_whitelist /path/to/whitelist/file.conf; location /static { js_challenge off; @@ -57,6 +58,7 @@ server { * `js_challenge_html "/path/to/file.html"` Path to html file to be inserted in the `` tag of the interstitial page * `js_challenge_title "title"` Will be inserted in the `` tag of the interstitial page. DEFAULT: "Verifying your browser..." * `js_challenge_bucket_duration time` Interval to prompt js challenge, in seconds. DEFAULT: 3600 +* `js_challenge_whitelist "/path/to/whitelist/file.conf"` Path to conf file containing whitelisted hosts and networks ### Installation diff --git a/ngx_http_js_challenge.c b/ngx_http_js_challenge.c index b0f375c..a7e9de4 100644 --- a/ngx_http_js_challenge.c +++ b/ngx_http_js_challenge.c @@ -27,7 +27,7 @@ #define DEFAULT_TITLE "Verifying your browser..." -#define WHITELIST_MAX_LENGTH 256 +#define WHITELIST_MAX_LENGTH 1024 typedef struct { @@ -219,7 +219,7 @@ static size_t load_whitelist( const char* file, network_info_t* list, size_t max } - } while ((token = strtok(NULL, ";")) != NULL); + } while (len < WHITELIST_MAX_LENGTH && ((token = strtok(NULL, ";")) != NULL)); } free(linebuf);