You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2015/01/02 22:08:55 UTC
[1/7] trafficserver git commit: Fix SSL session cache leak under lock
contention
Repository: trafficserver
Updated Branches:
refs/heads/master 325d1de3c -> 7d11e005d
Fix SSL session cache leak under lock contention
Coverity CID #1254820
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/79181c0d
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/79181c0d
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/79181c0d
Branch: refs/heads/master
Commit: 79181c0dd6868e73e6427819ef020261faeecb28
Parents: d823954
Author: James Peach <jp...@apache.org>
Authored: Mon Dec 29 21:36:06 2014 -0800
Committer: James Peach <jp...@apache.org>
Committed: Fri Jan 2 12:45:51 2015 -0800
----------------------------------------------------------------------
iocore/net/SSLSessionCache.cc | 15 ++++++++++-----
iocore/net/SSLSessionCache.h | 2 +-
2 files changed, 11 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/79181c0d/iocore/net/SSLSessionCache.cc
----------------------------------------------------------------------
diff --git a/iocore/net/SSLSessionCache.cc b/iocore/net/SSLSessionCache.cc
index 2d059fe..b3cbc1e 100644
--- a/iocore/net/SSLSessionCache.cc
+++ b/iocore/net/SSLSessionCache.cc
@@ -19,10 +19,10 @@
limitations under the License.
*/
-#include <cstring>
-#include <deque>
#include "P_SSLConfig.h"
#include "SSLSessionCache.h"
+#include <cstring>
+#include <memory>
#define SSLSESSIONCACHE_STRINGIFY0(x) #x
#define SSLSESSIONCACHE_STRINGIFY(x) SSLSESSIONCACHE_STRINGIFY0(x)
@@ -121,7 +121,7 @@ void SSLSessionBucket::insertSession(const SSLSessionID &id, SSL_SESSION *sess)
unsigned char *loc = reinterpret_cast<unsigned char *>(buf->data());
i2d_SSL_SESSION(sess, &loc);
- SSLSession *ssl_session = new SSLSession(id, buf, len);
+ std::auto_ptr<SSLSession> ssl_session(new SSLSession(id, buf, len));
MUTEX_TRY_LOCK(lock, mutex, this_ethread());
if (!lock.is_locked()) {
@@ -138,7 +138,7 @@ void SSLSessionBucket::insertSession(const SSLSessionID &id, SSL_SESSION *sess)
}
/* do the actual insert */
- queue.enqueue(ssl_session);
+ queue.enqueue(ssl_session.release());
PRINT_BUCKET("insertSession after")
}
@@ -200,7 +200,12 @@ void inline SSLSessionBucket::print(const char *ref_str) const {
}
}
-void inline SSLSessionBucket::removeOldestSession() {
+void inline
+SSLSessionBucket::removeOldestSession()
+{
+ // Caller must hold the bucket lock.
+ ink_assert(this_ethread() == mutex->thread_holding);
+
PRINT_BUCKET("removeOldestSession before")
while (queue.head && queue.size >= static_cast<int>(SSLConfigParams::session_cache_max_bucket_size)) {
SSLSession *old_head = queue.pop();
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/79181c0d/iocore/net/SSLSessionCache.h
----------------------------------------------------------------------
diff --git a/iocore/net/SSLSessionCache.h b/iocore/net/SSLSessionCache.h
index 240b251..a0e6f30 100644
--- a/iocore/net/SSLSessionCache.h
+++ b/iocore/net/SSLSessionCache.h
@@ -118,7 +118,6 @@ class SSLSessionBucket {
public:
SSLSessionBucket();
~SSLSessionBucket();
- void removeOldestSession();
void insertSession(const SSLSessionID &, SSL_SESSION *ctx);
bool getSession(const SSLSessionID &, SSL_SESSION **ctx);
void removeSession(const SSLSessionID &);
@@ -126,6 +125,7 @@ public:
private:
/* these method must be used while hold the lock */
void print(const char *) const;
+ void removeOldestSession();
Ptr<ProxyMutex> mutex;
CountQueue<SSLSession> queue;
[2/7] trafficserver git commit: Apply configured session sharing
settings
Posted by jp...@apache.org.
Apply configured session sharing settings
Coverity CID #1196453
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/a020cb29
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/a020cb29
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/a020cb29
Branch: refs/heads/master
Commit: a020cb2943f78f77ba8c928001359e8a2440cd28
Parents: c69a1b5
Author: James Peach <jp...@apache.org>
Authored: Mon Dec 29 12:48:08 2014 -0800
Committer: James Peach <jp...@apache.org>
Committed: Fri Jan 2 12:45:51 2015 -0800
----------------------------------------------------------------------
proxy/http/HttpConfig.cc | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a020cb29/proxy/http/HttpConfig.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpConfig.cc b/proxy/http/HttpConfig.cc
index 652a56a..bc345d9 100644
--- a/proxy/http/HttpConfig.cc
+++ b/proxy/http/HttpConfig.cc
@@ -83,11 +83,11 @@ template <typename T> struct ConfigEnumPair
/// @a n is the number of entries in the list.
/// @return @c true if the string is found, @c false if not found.
/// If found @a value is set to the corresponding value in @a list.
-template <typename T> static bool
-http_config_enum_search(char const* key, ConfigEnumPair<T>* list, size_t n, MgmtByte value)
+template <typename T, unsigned N> static bool
+http_config_enum_search(char const* key, const ConfigEnumPair<T> (&list)[N], MgmtByte& value)
{
// We don't expect any of these lists to be more than 10 long, so a linear search is the best choice.
- for ( size_t i = 0 ; i < n ; ++i ) {
+ for ( unsigned i = 0 ; i < N ; ++i ) {
if (0 == strcasecmp(list[i]._key, key)) {
value = list[i]._value;
return true;
@@ -100,18 +100,18 @@ http_config_enum_search(char const* key, ConfigEnumPair<T>* list, size_t n, Mgmt
/// @a n is the number of entries in the list.
/// @return @c true if the string is found, @c false if not found.
/// If found @a value is set to the corresponding value in @a list.
-template <typename T> static bool
-http_config_enum_read(char const* name, ConfigEnumPair<T>* list, size_t n, MgmtByte value)
+template <typename T, unsigned N> static bool
+http_config_enum_read(char const* name, const ConfigEnumPair<T> (&list)[N], MgmtByte& value)
{
char key[512]; // it's just one key - painful UI if keys are longer than this
if (REC_ERR_OKAY == RecGetRecordString(name, key, sizeof(key))) {
- return http_config_enum_search(key, list, n, value);
+ return http_config_enum_search(key, list, value);
}
return false;
}
/// Session sharing match types.
-static
+static const
ConfigEnumPair<TSServerSessionSharingMatchType> SessionSharingMatchStrings[] =
{
{ TS_SERVER_SESSION_SHARING_MATCH_NONE, "none" },
@@ -120,15 +120,13 @@ ConfigEnumPair<TSServerSessionSharingMatchType> SessionSharingMatchStrings[] =
{ TS_SERVER_SESSION_SHARING_MATCH_BOTH, "both" }
};
-static
+static const
ConfigEnumPair<TSServerSessionSharingPoolType> SessionSharingPoolStrings[] =
{
{ TS_SERVER_SESSION_SHARING_POOL_GLOBAL, "global" },
{ TS_SERVER_SESSION_SHARING_POOL_THREAD, "thread" }
};
-# define ARRAY_SIZE(x) (sizeof(x)/(sizeof((x)[0])))
-
////////////////////////////////////////////////////////////////
//
// static variables
@@ -211,7 +209,7 @@ http_server_session_sharing_cb(char const* name, RecDataT dtype, RecData data, v
MgmtByte& match = c->oride.server_session_sharing_match;
if (RECD_INT == dtype) {
match = static_cast<TSServerSessionSharingMatchType>(data.rec_int);
- } else if (RECD_STRING == dtype && http_config_enum_search(data.rec_string, SessionSharingMatchStrings, ARRAY_SIZE(SessionSharingMatchStrings), match)) {
+ } else if (RECD_STRING == dtype && http_config_enum_search(data.rec_string, SessionSharingMatchStrings, match)) {
// empty
} else {
valid_p = false;
@@ -220,7 +218,7 @@ http_server_session_sharing_cb(char const* name, RecDataT dtype, RecData data, v
MgmtByte& match = c->oride.server_session_sharing_pool;
if (RECD_INT == dtype) {
match = static_cast<TSServerSessionSharingPoolType>(data.rec_int);
- } else if (RECD_STRING == dtype && http_config_enum_search(data.rec_string, SessionSharingPoolStrings, ARRAY_SIZE(SessionSharingPoolStrings), match)) {
+ } else if (RECD_STRING == dtype && http_config_enum_search(data.rec_string, SessionSharingPoolStrings, match)) {
// empty
} else {
valid_p = false;
@@ -1291,9 +1289,9 @@ HttpConfig::startup()
// [amc] This is a bit of a mess, need to figure out to make this cleaner.
RecRegisterConfigUpdateCb("proxy.config.http.server_session_sharing.pool", &http_server_session_sharing_cb, &c);
- http_config_enum_read("proxy.config.http.server_session_sharing.pool", SessionSharingPoolStrings, ARRAY_SIZE(SessionSharingPoolStrings), c.oride.server_session_sharing_pool);
+ http_config_enum_read("proxy.config.http.server_session_sharing.pool", SessionSharingPoolStrings, c.oride.server_session_sharing_pool);
RecRegisterConfigUpdateCb("proxy.config.http.server_session_sharing.match", &http_server_session_sharing_cb, &c);
- http_config_enum_read("proxy.config.http.server_session_sharing.match", SessionSharingMatchStrings, ARRAY_SIZE(SessionSharingMatchStrings), c.oride.server_session_sharing_match);
+ http_config_enum_read("proxy.config.http.server_session_sharing.match", SessionSharingMatchStrings, c.oride.server_session_sharing_match);
HttpEstablishStaticConfigByte(c.oride.keep_alive_post_out, "proxy.config.http.keep_alive_post_out");
[7/7] trafficserver git commit: Fix record list termination memory
leak.
Posted by jp...@apache.org.
Fix record list termination memory leak.
Coverity CID #1237319
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/7d11e005
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/7d11e005
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/7d11e005
Branch: refs/heads/master
Commit: 7d11e005d002dbe9f4f6e6a5a01be37f4d516fc6
Parents: eba452d
Author: James Peach <jp...@apache.org>
Authored: Mon Dec 29 22:13:29 2014 -0800
Committer: James Peach <jp...@apache.org>
Committed: Fri Jan 2 12:45:52 2015 -0800
----------------------------------------------------------------------
mgmt/api/CoreAPIRemote.cc | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7d11e005/mgmt/api/CoreAPIRemote.cc
----------------------------------------------------------------------
diff --git a/mgmt/api/CoreAPIRemote.cc b/mgmt/api/CoreAPIRemote.cc
index 11b647b..67de06f 100644
--- a/mgmt/api/CoreAPIRemote.cc
+++ b/mgmt/api/CoreAPIRemote.cc
@@ -575,11 +575,13 @@ MgmtRecordGetMatching(const char * regex, TSList rec_vals)
// parse the reply to get record value and type
ret = mgmt_record_get_reply(RECORD_MATCH_GET, rec_ele);
if (ret != TS_ERR_OKAY) {
+ TSRecordEleDestroy(rec_ele);
goto fail;
}
// A NULL record ends the list.
if (rec_ele->rec_type == TS_REC_UNDEFINED) {
+ TSRecordEleDestroy(rec_ele);
break;
}
@@ -590,7 +592,6 @@ MgmtRecordGetMatching(const char * regex, TSList rec_vals)
fail:
- TSRecordEleDestroy(rec_ele);
for (rec_ele = (TSRecordEle *) dequeue((LLQ *) rec_vals); rec_ele; rec_ele = (TSRecordEle *) dequeue((LLQ *) rec_vals)) {
TSRecordEleDestroy(rec_ele);
}
[4/7] trafficserver git commit: Fix open(2) failure check
Posted by jp...@apache.org.
Fix open(2) failure check
Coverity CID #1021880
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/d823954c
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/d823954c
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/d823954c
Branch: refs/heads/master
Commit: d823954cbf0dc9c7f9c4498dcde3fa14a1bcc230
Parents: a020cb2
Author: James Peach <jp...@apache.org>
Authored: Mon Dec 29 21:23:18 2014 -0800
Committer: James Peach <jp...@apache.org>
Committed: Fri Jan 2 12:45:51 2015 -0800
----------------------------------------------------------------------
proxy/logging/LogFile.cc | 47 ++++++++++++++++++++++---------------------
1 file changed, 24 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d823954c/proxy/logging/LogFile.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogFile.cc b/proxy/logging/LogFile.cc
index e86a7ef..6f2a91f 100644
--- a/proxy/logging/LogFile.cc
+++ b/proxy/logging/LogFile.cc
@@ -865,32 +865,33 @@ MetaInfo::_read_from_file()
void
MetaInfo::_write_to_file()
{
- int fd = open(_filename, O_WRONLY | O_CREAT | O_TRUNC,
- Log::config->logfile_perm);
-
- if (fd <= 0) {
+ int fd = open(_filename, O_WRONLY | O_CREAT | O_TRUNC, Log::config->logfile_perm);
+ if (fd < 0) {
Warning("Could not open metafile %s for writing: %s", _filename, strerror(errno));
- } else {
- int n;
- if (_flags & VALID_CREATION_TIME) {
- n = snprintf(_buffer, BUF_SIZE, "creation_time = %lu\n", (unsigned long) _creation_time);
- // TODO modify this runtime check so that it is not an assertion
- ink_release_assert(n <= BUF_SIZE);
- if (write(fd, _buffer, n) == -1) {
- Warning("Could not write creation_time");
- }
+ return;
+ }
+
+ int n;
+ if (_flags & VALID_CREATION_TIME) {
+ n = snprintf(_buffer, BUF_SIZE, "creation_time = %lu\n", (unsigned long) _creation_time);
+ // TODO modify this runtime check so that it is not an assertion
+ ink_release_assert(n <= BUF_SIZE);
+ if (write(fd, _buffer, n) == -1) {
+ Warning("Could not write creation_time");
}
- if (_flags & VALID_SIGNATURE) {
- n = snprintf(_buffer, BUF_SIZE, "object_signature = %" PRIu64 "\n", _log_object_signature);
- // TODO modify this runtime check so that it is not an assertion
- ink_release_assert(n <= BUF_SIZE);
- if (write(fd, _buffer, n) == -1) {
- Warning("Could not write object_signaure");
- }
- Debug("log-meta", "MetaInfo::_write_to_file\n"
- "\tfilename = %s\n"
- "\tsignature value = %" PRIu64 "\n" "\tsignature string = %s", _filename, _log_object_signature, _buffer);
+ }
+
+ if (_flags & VALID_SIGNATURE) {
+ n = snprintf(_buffer, BUF_SIZE, "object_signature = %" PRIu64 "\n", _log_object_signature);
+ // TODO modify this runtime check so that it is not an assertion
+ ink_release_assert(n <= BUF_SIZE);
+ if (write(fd, _buffer, n) == -1) {
+ Warning("Could not write object_signaure");
}
+ Debug("log-meta", "MetaInfo::_write_to_file\n"
+ "\tfilename = %s\n"
+ "\tsignature value = %" PRIu64 "\n" "\tsignature string = %s", _filename, _log_object_signature, _buffer);
}
+
close(fd);
}
[5/7] trafficserver git commit: Prevent out of bounds write in
argument parsing
Posted by jp...@apache.org.
Prevent out of bounds write in argument parsing
Coverity CID #1254806
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/15ae8f09
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/15ae8f09
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/15ae8f09
Branch: refs/heads/master
Commit: 15ae8f09064eae19ab0aebe44842fc209e63ab6d
Parents: 79181c0
Author: James Peach <jp...@apache.org>
Authored: Mon Dec 29 21:45:10 2014 -0800
Committer: James Peach <jp...@apache.org>
Committed: Fri Jan 2 12:45:52 2015 -0800
----------------------------------------------------------------------
lib/ts/ink_args.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/15ae8f09/lib/ts/ink_args.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_args.cc b/lib/ts/ink_args.cc
index 57f82c8..87bd114 100644
--- a/lib/ts/ink_args.cc
+++ b/lib/ts/ink_args.cc
@@ -68,8 +68,8 @@ append_file_argument(const char * arg)
if (n_file_arguments >= countof(file_arguments)) {
ink_fatal("too many files");
}
+
file_arguments[n_file_arguments++] = arg;
- file_arguments[n_file_arguments] = NULL;
}
static void
[3/7] trafficserver git commit: header_rewrite: remove static hook
names array
Posted by jp...@apache.org.
header_rewrite: remove static hook names array
Coverity CID #1254807
Coverity CID #1254799
Coverity CID #1254821
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/c69a1b55
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/c69a1b55
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/c69a1b55
Branch: refs/heads/master
Commit: c69a1b55501ef2e9d2d02fabbbf46043c01bba01
Parents: 325d1de
Author: James Peach <jp...@apache.org>
Authored: Mon Dec 29 12:14:17 2014 -0800
Committer: James Peach <jp...@apache.org>
Committed: Fri Jan 2 12:45:51 2015 -0800
----------------------------------------------------------------------
plugins/header_rewrite/header_rewrite.cc | 30 ++++-----------------------
plugins/header_rewrite/resources.cc | 6 +-----
2 files changed, 5 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c69a1b55/plugins/header_rewrite/header_rewrite.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/header_rewrite.cc b/plugins/header_rewrite/header_rewrite.cc
index 1202545..a97b8ab 100644
--- a/plugins/header_rewrite/header_rewrite.cc
+++ b/plugins/header_rewrite/header_rewrite.cc
@@ -29,28 +29,6 @@
const char PLUGIN_NAME[] = "header_rewrite";
const char PLUGIN_NAME_DBG[] = "dbg_header_rewrite";
-const char* HOOK_NAMES[] = {
- "TS_HTTP_READ_REQUEST_HDR_HOOK",
- "TS_HTTP_OS_DNS_HOOK",
- "TS_HTTP_SEND_REQUEST_HDR_HOOK",
- "TS_HTTP_READ_CACHE_HDR_HOOK",
- "TS_HTTP_READ_RESPONSE_HDR_HOOK",
- "TS_HTTP_SEND_RESPONSE_HDR_HOOK",
- "TS_HTTP_REQUEST_TRANSFORM_HOOK",
- "TS_HTTP_RESPONSE_TRANSFORM_HOOK",
- "TS_HTTP_SELECT_ALT_HOOK",
- "TS_HTTP_TXN_START_HOOK",
- "TS_HTTP_TXN_CLOSE_HOOK",
- "TS_HTTP_SSN_START_HOOK",
- "TS_HTTP_SSN_CLOSE_HOOK",
- "TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK",
- "TS_HTTP_PRE_REMAP_HOOK",
- "TS_HTTP_POST_REMAP_HOOK",
- "TS_HTTP_RESPONSE_CLIENT_HOOK",
- "TS_HTTP_LAST_HOOK"
-};
-
-
// Forward declaration for the main continuation.
static int cont_rewrite_headers(TSCont, TSEvent, void *);
@@ -98,7 +76,7 @@ bool
RulesConfig::add_rule(RuleSet* rule)
{
if (rule && rule->has_operator()) {
- TSDebug(PLUGIN_NAME_DBG, " Adding rule to hook=%s\n", HOOK_NAMES[rule->get_hook()]);
+ TSDebug(PLUGIN_NAME_DBG, " Adding rule to hook=%s\n", TSHttpHookNameLookup(rule->get_hook()));
if (NULL == _rules[rule->get_hook()]) {
_rules[rule->get_hook()] = rule;
} else {
@@ -317,7 +295,7 @@ TSPluginInit(int argc, const char *argv[])
for (int i=TS_HTTP_READ_REQUEST_HDR_HOOK; i<TS_HTTP_LAST_HOOK; ++i) {
if (conf->rule(i)) {
- TSDebug(PLUGIN_NAME, "Adding global ruleset to hook=%s", HOOK_NAMES[i]);
+ TSDebug(PLUGIN_NAME, "Adding global ruleset to hook=%s", TSHttpHookNameLookup((TSHttpHookID)i));
TSHttpHookAdd(static_cast<TSHttpHookID>(i), contp);
}
}
@@ -382,7 +360,7 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, char * /* errbuf ATS_UNUSE
if (TSIsDebugTagSet(PLUGIN_NAME)) {
for (int i=TS_HTTP_READ_REQUEST_HDR_HOOK; i<TS_HTTP_LAST_HOOK; ++i) {
if (conf->rule(i)) {
- TSDebug(PLUGIN_NAME, "Adding remap ruleset to hook=%s", HOOK_NAMES[i]);
+ TSDebug(PLUGIN_NAME, "Adding remap ruleset to hook=%s", TSHttpHookNameLookup((TSHttpHookID)i));
}
}
}
@@ -420,7 +398,7 @@ TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
for (int i=TS_HTTP_READ_REQUEST_HDR_HOOK; i<TS_HTTP_LAST_HOOK; ++i) {
if (conf->rule(i)) {
TSHttpTxnHookAdd(rh, static_cast<TSHttpHookID>(i), conf->continuation());
- TSDebug(PLUGIN_NAME, "Added remapped TXN hook=%s", HOOK_NAMES[i]);
+ TSDebug(PLUGIN_NAME, "Added remapped TXN hook=%s", TSHttpHookNameLookup((TSHttpHookID)i));
}
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c69a1b55/plugins/header_rewrite/resources.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/resources.cc b/plugins/header_rewrite/resources.cc
index 8e34d3b..a1992ca 100644
--- a/plugins/header_rewrite/resources.cc
+++ b/plugins/header_rewrite/resources.cc
@@ -24,15 +24,11 @@
#include "resources.h"
#include "lulu.h"
-// This is defined in header_rewrite.cc, used here for debugging
-extern char* HOOK_NAMES[];
-
-
// Collect all resources
void
Resources::gather(const ResourceIDs ids, TSHttpHookID hook)
{
- TSDebug(PLUGIN_NAME, "Building resources, hook=%s", HOOK_NAMES[hook]);
+ TSDebug(PLUGIN_NAME, "Building resources, hook=%s", TSHttpHookNameLookup(hook));
// If we need the client request headers, make sure it's also available in the client vars.
if (ids & RSRC_CLIENT_REQUEST_HEADERS) {
[6/7] trafficserver git commit: Fix hook ID bounds checking
Posted by jp...@apache.org.
Fix hook ID bounds checking
Coverity CID #1242006
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/eba452d5
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/eba452d5
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/eba452d5
Branch: refs/heads/master
Commit: eba452d5f876858d97984976a9245f98f1f915d4
Parents: 15ae8f0
Author: James Peach <jp...@apache.org>
Authored: Mon Dec 29 22:04:04 2014 -0800
Committer: James Peach <jp...@apache.org>
Committed: Fri Jan 2 12:45:52 2015 -0800
----------------------------------------------------------------------
proxy/InkAPI.cc | 8 ++------
proxy/InkAPIInternal.h | 18 ++++++++++++------
2 files changed, 14 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/eba452d5/proxy/InkAPI.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index 62f0870..fdb5bde 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -631,17 +631,13 @@ sdk_sanity_check_alt_info(TSHttpAltInfo info)
TSReturnCode
sdk_sanity_check_hook_id(TSHttpHookID id)
{
- if (id<TS_HTTP_READ_REQUEST_HDR_HOOK || id> TS_HTTP_LAST_HOOK)
- return TS_ERROR;
- return TS_SUCCESS;
+ return HttpAPIHooks::is_valid(id) ? TS_SUCCESS : TS_ERROR;
}
TSReturnCode
sdk_sanity_check_lifecycle_hook_id(TSLifecycleHookID id)
{
- if (id<TS_LIFECYCLE_PORTS_INITIALIZED_HOOK || id> TS_LIFECYCLE_LAST_HOOK)
- return TS_ERROR;
- return TS_SUCCESS;
+ return LifecycleAPIHooks::is_valid(id) ? TS_SUCCESS : TS_ERROR;
}
TSReturnCode
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/eba452d5/proxy/InkAPIInternal.h
----------------------------------------------------------------------
diff --git a/proxy/InkAPIInternal.h b/proxy/InkAPIInternal.h
index 79a948b..49dc0bf 100644
--- a/proxy/InkAPIInternal.h
+++ b/proxy/InkAPIInternal.h
@@ -246,30 +246,36 @@ template < typename ID, ID N >
void
FeatureAPIHooks<ID,N>::prepend(ID id, INKContInternal *cont)
{
- hooks_p = true;
- m_hooks[id].prepend(cont);
+ if (likely(is_valid(id))) {
+ hooks_p = true;
+ m_hooks[id].prepend(cont);
+ }
}
template < typename ID, ID N >
void
FeatureAPIHooks<ID,N>::append(ID id, INKContInternal *cont)
{
- hooks_p = true;
- m_hooks[id].append(cont);
+ if (likely(is_valid(id))) {
+ hooks_p = true;
+ m_hooks[id].append(cont);
+ }
}
template < typename ID, ID N >
APIHook *
FeatureAPIHooks<ID,N>::get(ID id) const
{
- return m_hooks[id].get();
+ return likely(is_valid(id)) ? m_hooks[id].get() : NULL;
}
template < typename ID, ID N >
void
FeatureAPIHooks<ID,N>::invoke(ID id, int event, void* data)
{
- m_hooks[id].invoke(event, data);
+ if (likely(is_valid(id))) {
+ m_hooks[id].invoke(event, data);
+ }
}
template < typename ID, ID N >