Repository: trafficserver Updated Branches: refs/heads/master 4a4507216 -> 3eb7c1e7e
[TS-3531]: Ignore blank lines in the plugin config file Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/f39aaba1 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/f39aaba1 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/f39aaba1 Branch: refs/heads/master Commit: f39aaba197a4f4d6559a94aa5b8ffa5dcfc3c3b6 Parents: 4a45072 Author: Sudheer Vinukonda <sudhe...@yahoo-inc.com> Authored: Fri May 1 21:40:27 2015 +0000 Committer: Sudheer Vinukonda <sudhe...@yahoo-inc.com> Committed: Fri May 1 21:40:27 2015 +0000 ---------------------------------------------------------------------- plugins/cacheurl/cacheurl.cc | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f39aaba1/plugins/cacheurl/cacheurl.cc ---------------------------------------------------------------------- diff --git a/plugins/cacheurl/cacheurl.cc b/plugins/cacheurl/cacheurl.cc index e01407d..5f03598 100644 --- a/plugins/cacheurl/cacheurl.cc +++ b/plugins/cacheurl/cacheurl.cc @@ -236,17 +236,23 @@ load_config_file(const char *config_file) while (TSfgets(fh, buffer, sizeof(buffer) - 1)) { lineno++; - if (*buffer == '#') { - /* # Comments, only at line beginning */ + + // make sure line was not bigger than buffer + if ((eol = strchr(buffer, '\n')) == NULL && (eol = strstr(buffer, "\r\n")) == NULL) { + // Malformed line - skip + TSError("%s: config line too long, did not get a good line in cfg, skipping, line: %s", PLUGIN_NAME, buffer); + memset(buffer, 0, sizeof(buffer)); continue; - } - eol = strstr(buffer, "\n"); - if (eol) { - *eol = 0; /* Terminate string at newline */ } else { - /* Malformed line - skip */ + *eol = 0; + } + // make sure line has something useful on it + // or allow # Comments, only at line beginning + if (eol - buffer < 2 || buffer[0] == '#') { + memset(buffer, 0, sizeof(buffer)); continue; } + /* Split line into two parts based on whitespace */ /* Find first whitespace */ spstart = strstr(buffer, " "); @@ -434,6 +440,7 @@ TSPluginInit(int argc, const char *argv[]) info.support_email = (char *)"d...@trafficserver.apache.org"; if (TSPluginRegister(TS_SDK_VERSION_3_0, &info) != TS_SUCCESS) { + TSDebug(PLUGIN_NAME, "ERROR, Plugin registration failed"); initialization_error("Plugin registration failed."); return; } @@ -444,5 +451,9 @@ TSPluginInit(int argc, const char *argv[]) /* Store the pattern replacement list in the continuation */ TSContDataSet(contp, prl); TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, contp); + } else { + TSDebug(PLUGIN_NAME, "ERROR, Plugin config load failed."); + initialization_error("Plugin config load failed."); + return; } }