trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kic...@apache.org
Subject [trafficserver] branch master updated: coverity fixes for esi
Date Wed, 07 Jun 2017 22:18:54 GMT
This is an automated email from the ASF dual-hosted git repository.

kichan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new f770aaa  coverity fixes for esi
f770aaa is described below

commit f770aaa50271cc355a83ae5ac9a173013688fac5
Author: Kit Chan <kichan@apache.org>
AuthorDate: Sat Jun 3 16:29:29 2017 -0700

    coverity fixes for esi
---
 plugins/esi/lib/EsiProcessor.cc | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/plugins/esi/lib/EsiProcessor.cc b/plugins/esi/lib/EsiProcessor.cc
index 59df2be..f46f02a 100644
--- a/plugins/esi/lib/EsiProcessor.cc
+++ b/plugins/esi/lib/EsiProcessor.cc
@@ -179,15 +179,20 @@ EsiProcessor::_getIncludeStatus(const DocNode &node)
               processed_url.data());
     return status;
   } else if (node.type == DocNode::TYPE_SPECIAL_INCLUDE) {
-    AttributeList::const_iterator attr_iter;
-    for (attr_iter = node.attr_list.begin(); attr_iter != node.attr_list.end(); ++attr_iter)
{
+    int include_data_id            = 0;
+    SpecialIncludeHandler *handler = nullptr;
+    for (AttributeList::const_iterator attr_iter = node.attr_list.begin(); attr_iter != node.attr_list.end();
++attr_iter) {
       if (attr_iter->name == INCLUDE_DATA_ID_ATTR) {
+        include_data_id = attr_iter->value_len;
+        handler         = reinterpret_cast<SpecialIncludeHandler *>(const_cast<char
*>(attr_iter->value));
         break;
       }
     }
-    int include_data_id            = attr_iter->value_len;
-    SpecialIncludeHandler *handler = reinterpret_cast<SpecialIncludeHandler *>(const_cast<char
*>(attr_iter->value));
-    DataStatus status              = handler->getIncludeStatus(include_data_id);
+    if (include_data_id == 0 || handler == nullptr) {
+      _errorLog("[%s] Fail to find the special include data id attribute", __FUNCTION__);
+      return STATUS_ERROR;
+    }
+    DataStatus status = handler->getIncludeStatus(include_data_id);
     _debugLog(_debug_tag, "[%s] Successfully got status for special include with id %d",
__FUNCTION__, status, include_data_id);
 
     return status;
@@ -233,14 +238,20 @@ EsiProcessor::_getIncludeData(const DocNode &node, const char **content_ptr
/* =
     _debugLog(_debug_tag, "[%s] Got content successfully for URL [%.*s]", __FUNCTION__, processed_url.size(),
processed_url.data());
     return true;
   } else if (node.type == DocNode::TYPE_SPECIAL_INCLUDE) {
-    AttributeList::const_iterator attr_iter;
-    for (attr_iter = node.attr_list.begin(); attr_iter != node.attr_list.end(); ++attr_iter)
{
+    int include_data_id            = 0;
+    SpecialIncludeHandler *handler = nullptr;
+    for (AttributeList::const_iterator attr_iter = node.attr_list.begin(); attr_iter != node.attr_list.end();
++attr_iter) {
       if (attr_iter->name == INCLUDE_DATA_ID_ATTR) {
+        include_data_id = attr_iter->value_len;
+        handler         = reinterpret_cast<SpecialIncludeHandler *>(const_cast<char
*>(attr_iter->value));
         break;
       }
     }
-    int include_data_id            = attr_iter->value_len;
-    SpecialIncludeHandler *handler = reinterpret_cast<SpecialIncludeHandler *>(const_cast<char
*>(attr_iter->value));
+    if (include_data_id == 0 || handler == nullptr) {
+      _errorLog("[%s] Fail to find the special include data id attribute", __FUNCTION__);
+      Stats::increment(Stats::N_SPCL_INCLUDE_ERRS);
+      return false;
+    }
     bool result;
     if (content_ptr && content_len_ptr) {
       result = handler->getData(include_data_id, *content_ptr, *content_len_ptr);

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <commits@trafficserver.apache.org>'].

Mime
View raw message