[
https://issues.apache.org/jira/browse/TS-3531?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14523574#comment-14523574
]
Sudheer Vinukonda commented on TS-3531:
---------------------------------------
Below patch allows to ignore blank lines and asserts on a config load failure.
{code}
18:17:33 sudheerv ~/source/master/trafficserver/plugins/cacheurl (master) $ git
diff
diff --git a/plugins/cacheurl/cacheurl.cc b/plugins/cacheurl/cacheurl.cc
index e01407d..1a8d040 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, " ");
@@ -435,6 +441,7 @@ TSPluginInit(int argc, const char *argv[])
if (TSPluginRegister(TS_SDK_VERSION_3_0, &info) != TS_SUCCESS) {
initialization_error("Plugin registration failed.");
+ TSReleaseAssert("Plugin registration failed.");
return;
}
@@ -444,5 +451,8 @@ 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 {
+ TSReleaseAssert("Plugin config load failed.");
+ return;
}
}
{code}
> cacheurl plugin not working in 5.3.0->5.3.x
> -------------------------------------------
>
> Key: TS-3531
> URL: https://issues.apache.org/jira/browse/TS-3531
> Project: Traffic Server
> Issue Type: Bug
> Components: Cache, Plugins
> Reporter: Faysal Banna
> Fix For: 6.0.0
>
>
> Hi Guys
> was working and doing tests on 5.3.0 before i could integrate it in my
> production servers, and while doing so i noticed some issues with cacheurl
> plugin and maybe other plugins but that i can not confirm.
> Here is what my observation was :
> in cacheurl.config i have
> http://s1.2mdn.net/viewad/4079501/BeitMisk_Spring_160x600_web.gif
> http://tested/switched.gif
> loaded cacheurl.so cacheurl.config in plugin.config
> and i confirm that i get [Apr 18 02:45:54.442] Server {0x2b05b69fba80} DIAG:
> (cacheurl) Adding pattern/replacement pair:
> 'http://s1.2mdn.net/viewad/4079501/BeitMisk_Spring_160x600_web.gif' ->
> 'http://tested/switched.gif'
> in traffic.out
> which says that the pattern was added correctly
> nevertheless when i do curl or wget with xdebug header request
> i get :
> X-Cache-Key: http://s1.2mdn.net/viewad/4079501/BeitMisk_Spring_160x600_web.gif
> meaning that the cacheurl plugin didn't actually do the mapping in any way
> possible
> Next was testing with 5.2.1 version of ATS to see how things go so i git
> cloned it and compiled and ran the same test again
> now i get
> X-Cache-Key: http://tested/switched.gif
> which means that cacheurl in 5.2.1 works while in latest mainstream or 5.3.0
> it does not
> i shall do further tests and feed you back here
> much regards
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)