You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by so...@apache.org on 2015/05/05 06:21:22 UTC

[10/11] trafficserver git commit: TS-3531: Ignore blank lines in the plugin config file

TS-3531: Ignore blank lines in the plugin config file

(cherry picked from commit f39aaba197a4f4d6559a94aa5b8ffa5dcfc3c3b6)


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/68913f77
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/68913f77
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/68913f77

Branch: refs/heads/5.3.x
Commit: 68913f77e4c8851cdfee3821b4d8278eba5705eb
Parents: 1801eef
Author: Sudheer Vinukonda <su...@yahoo-inc.com>
Authored: Fri May 1 21:40:27 2015 +0000
Committer: Phil Sorber <so...@apache.org>
Committed: Mon May 4 21:40:28 2015 -0600

----------------------------------------------------------------------
 CHANGES                      |  2 ++
 plugins/cacheurl/cacheurl.cc | 25 ++++++++++++++++++-------
 2 files changed, 20 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/68913f77/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index d5d994b..4a8387b 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.3.0
 
+  *) [TS-3531] Ignore blank lines in the plugin config file.
+
   *) [TS-3573] Fix connection leak.
 
   *) [TS-3558] Fix proxy.config.http.auth_server_session_private

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/68913f77/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 *)"dev@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;
   }
 }