You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2016/04/05 00:04:48 UTC
trafficserver git commit: TS-4310 Fixes coverity issue 1353635,
1353636 and 1353637
Repository: trafficserver
Updated Branches:
refs/heads/master 692437fad -> baa615072
TS-4310 Fixes coverity issue 1353635, 1353636 and 1353637
This closes #544
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/baa61507
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/baa61507
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/baa61507
Branch: refs/heads/master
Commit: baa61507293e7c7cd7d6c4dd4cbdc431961a55a0
Parents: 692437f
Author: Leif Hedstrom <zw...@apache.org>
Authored: Mon Mar 28 16:23:50 2016 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 4 16:03:44 2016 -0600
----------------------------------------------------------------------
example/append-transform/append-transform.c | 50 ++++++++++----------
example/bnull-transform/bnull-transform.c | 13 ++---
example/null-transform/null-transform.c | 13 ++---
example/thread-pool/psi.c | 44 ++++++++---------
.../stale_while_revalidate.c | 16 +++----
plugins/gzip/gzip.cc | 29 ++++++------
6 files changed, 79 insertions(+), 86 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/baa61507/example/append-transform/append-transform.c
----------------------------------------------------------------------
diff --git a/example/append-transform/append-transform.c b/example/append-transform/append-transform.c
index 87c9c60..5ede811 100644
--- a/example/append-transform/append-transform.c
+++ b/example/append-transform/append-transform.c
@@ -249,31 +249,31 @@ transformable(TSHttpTxn txnp)
const char *value;
int val_length;
- TSHttpTxnServerRespGet(txnp, &bufp, &hdr_loc);
-
- /*
- * We are only interested in "200 OK" responses.
- */
-
- if (TS_HTTP_STATUS_OK == (resp_status = TSHttpHdrStatusGet(bufp, hdr_loc))) {
- /* We only want to do the transformation on documents that have a
- content type of "text/html". */
- field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, "Content-Type", 12);
- if (!field_loc) {
- ASSERT_SUCCESS(TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc));
- return 0;
- }
-
- value = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, -1, &val_length);
- if (value && (strncasecmp(value, "text/html", sizeof("text/html") - 1) == 0)) {
- ASSERT_SUCCESS(TSHandleMLocRelease(bufp, hdr_loc, field_loc));
- ASSERT_SUCCESS(TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc));
-
- return 1;
- } else {
- ASSERT_SUCCESS(TSHandleMLocRelease(bufp, hdr_loc, field_loc));
- ASSERT_SUCCESS(TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc));
- return 0;
+ if (TS_SUCCESS == TSHttpTxnServerRespGet(txnp, &bufp, &hdr_loc)) {
+ /*
+ * We are only interested in "200 OK" responses.
+ */
+
+ if (TS_HTTP_STATUS_OK == (resp_status = TSHttpHdrStatusGet(bufp, hdr_loc))) {
+ /* We only want to do the transformation on documents that have a
+ content type of "text/html". */
+ field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, "Content-Type", 12);
+ if (!field_loc) {
+ ASSERT_SUCCESS(TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc));
+ return 0;
+ }
+
+ value = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, -1, &val_length);
+ if (value && (strncasecmp(value, "text/html", sizeof("text/html") - 1) == 0)) {
+ ASSERT_SUCCESS(TSHandleMLocRelease(bufp, hdr_loc, field_loc));
+ ASSERT_SUCCESS(TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc));
+
+ return 1;
+ } else {
+ ASSERT_SUCCESS(TSHandleMLocRelease(bufp, hdr_loc, field_loc));
+ ASSERT_SUCCESS(TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc));
+ return 0;
+ }
}
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/baa61507/example/bnull-transform/bnull-transform.c
----------------------------------------------------------------------
diff --git a/example/bnull-transform/bnull-transform.c b/example/bnull-transform/bnull-transform.c
index e87d337..5dbdf99 100644
--- a/example/bnull-transform/bnull-transform.c
+++ b/example/bnull-transform/bnull-transform.c
@@ -260,17 +260,14 @@ transformable(TSHttpTxn txnp)
TSMBuffer bufp;
TSMLoc hdr_loc;
TSHttpStatus resp_status;
- int retv;
+ int retv = 0;
/* We are only interested in transforming "200 OK" responses. */
- TSHttpTxnServerRespGet(txnp, &bufp, &hdr_loc);
- resp_status = TSHttpHdrStatusGet(bufp, hdr_loc);
- retv = (resp_status == TS_HTTP_STATUS_OK);
-
- if (TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc) == TS_ERROR) {
- TSError("[bnull-transform] Error releasing MLOC while checking "
- "header status");
+ if (TS_SUCCESS == TSHttpTxnServerRespGet(txnp, &bufp, &hdr_loc)) {
+ resp_status = TSHttpHdrStatusGet(bufp, hdr_loc);
+ retv = (resp_status == TS_HTTP_STATUS_OK);
+ TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
}
return retv;
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/baa61507/example/null-transform/null-transform.c
----------------------------------------------------------------------
diff --git a/example/null-transform/null-transform.c b/example/null-transform/null-transform.c
index c8f101a..b9b94d4 100644
--- a/example/null-transform/null-transform.c
+++ b/example/null-transform/null-transform.c
@@ -255,17 +255,14 @@ transformable(TSHttpTxn txnp)
TSMBuffer bufp;
TSMLoc hdr_loc;
TSHttpStatus resp_status;
- int retv;
+ int retv = 0;
TSDebug("null-transform", "Entering transformable()");
- TSHttpTxnServerRespGet(txnp, &bufp, &hdr_loc);
- resp_status = TSHttpHdrStatusGet(bufp, hdr_loc);
- retv = (resp_status == TS_HTTP_STATUS_OK);
-
- if (TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc) == TS_ERROR) {
- TSError("[null-transform] Error releasing MLOC while checking "
- "header status");
+ if (TS_SUCCESS == TSHttpTxnServerRespGet(txnp, &bufp, &hdr_loc)) {
+ resp_status = TSHttpHdrStatusGet(bufp, hdr_loc);
+ retv = (resp_status == TS_HTTP_STATUS_OK);
+ TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
}
TSDebug("null-transform", "Exiting transformable with return %d", retv);
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/baa61507/example/thread-pool/psi.c
----------------------------------------------------------------------
diff --git a/example/thread-pool/psi.c b/example/thread-pool/psi.c
index 142c1fc..8fd93c9 100644
--- a/example/thread-pool/psi.c
+++ b/example/thread-pool/psi.c
@@ -887,34 +887,34 @@ transformable(TSHttpTxn txnp)
TSHttpStatus resp_status;
const char *value;
- TSHttpTxnServerRespGet(txnp, &bufp, &hdr_loc);
+ if (TS_SUCCESS == TSHttpTxnServerRespGet(txnp, &bufp, &hdr_loc)) {
+ resp_status = TSHttpHdrStatusGet(bufp, hdr_loc);
+ if (resp_status != TS_HTTP_STATUS_OK) {
+ TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
+ return 0;
+ }
- resp_status = TSHttpHdrStatusGet(bufp, hdr_loc);
- if (resp_status != TS_HTTP_STATUS_OK) {
- TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
- return 0;
- }
+ field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, TS_MIME_FIELD_CONTENT_TYPE, -1);
+ if (field_loc == TS_NULL_MLOC) {
+ TSError("[psi] Unable to search Content-Type field");
+ TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
+ return 0;
+ }
- field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, TS_MIME_FIELD_CONTENT_TYPE, -1);
- if (field_loc == TS_NULL_MLOC) {
- TSError("[psi] Unable to search Content-Type field");
- TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
- return 0;
- }
+ value = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, -1, NULL);
+ if ((value == NULL) || (strncasecmp(value, "text/", sizeof("text/") - 1) != 0)) {
+ TSHandleMLocRelease(bufp, hdr_loc, field_loc);
+ TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
+ return 0;
+ }
- value = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, -1, NULL);
- if ((value == NULL) || (strncasecmp(value, "text/", sizeof("text/") - 1) != 0)) {
TSHandleMLocRelease(bufp, hdr_loc, field_loc);
- TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
- return 0;
- }
- TSHandleMLocRelease(bufp, hdr_loc, field_loc);
+ field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, MIME_FIELD_XPSI, -1);
- field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, MIME_FIELD_XPSI, -1);
-
- TSHandleMLocRelease(bufp, hdr_loc, field_loc);
- TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
+ TSHandleMLocRelease(bufp, hdr_loc, field_loc);
+ TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
+ }
return 1;
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/baa61507/plugins/experimental/stale_while_revalidate/stale_while_revalidate.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/stale_while_revalidate/stale_while_revalidate.c b/plugins/experimental/stale_while_revalidate/stale_while_revalidate.c
index 8422602..341a710 100644
--- a/plugins/experimental/stale_while_revalidate/stale_while_revalidate.c
+++ b/plugins/experimental/stale_while_revalidate/stale_while_revalidate.c
@@ -573,18 +573,18 @@ main_plugin(TSCont cont, TSEvent event, void *edata)
}
break;
case TS_EVENT_HTTP_READ_RESPONSE_HDR:
- TSHttpTxnServerRespGet(txn, &buf, &loc);
- http_status = TSHttpHdrStatusGet(buf, loc);
- if ((http_status == 500) || ((http_status >= 502) && (http_status <= 504))) // 500, 502, 503, or 504
- {
- TSDebug(PLUGIN_NAME, "Set non-cachable");
+ if (TS_SUCCESS == TSHttpTxnServerRespGet(txn, &buf, &loc)) {
+ http_status = TSHttpHdrStatusGet(buf, loc);
+ if ((http_status == 500) || ((http_status >= 502) && (http_status <= 504))) { // 500, 502, 503, or 504
+ TSDebug(PLUGIN_NAME, "Set non-cachable");
#if (TS_VERSION_NUMBER >= 3003000)
- TSHttpTxnServerRespNoStoreSet(txn, 1);
+ TSHttpTxnServerRespNoStoreSet(txn, 1);
#else
- TSHttpTxnServerRespNoStore(txn);
+ TSHttpTxnServerRespNoStore(txn);
#endif
+ }
+ TSHandleMLocRelease(buf, TS_NULL_MLOC, loc);
}
- TSHandleMLocRelease(buf, TS_NULL_MLOC, loc);
TSHttpTxnReenable(txn, TS_EVENT_HTTP_CONTINUE);
break;
case TS_EVENT_HTTP_SEND_RESPONSE_HDR:
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/baa61507/plugins/gzip/gzip.cc
----------------------------------------------------------------------
diff --git a/plugins/gzip/gzip.cc b/plugins/gzip/gzip.cc
index 74aa1f8..2d345a6 100644
--- a/plugins/gzip/gzip.cc
+++ b/plugins/gzip/gzip.cc
@@ -472,21 +472,27 @@ gzip_transformable(TSHttpTxn txnp, bool server, HostConfiguration *host_configur
TSHttpStatus resp_status;
if (server) {
- TSHttpTxnServerRespGet(txnp, &bufp, &hdr_loc);
+ if (TS_SUCCESS != TSHttpTxnServerRespGet(txnp, &bufp, &hdr_loc)) {
+ return 0;
+ }
} else {
- TSHttpTxnCachedRespGet(txnp, &bufp, &hdr_loc);
+ if (TS_SUCCESS != TSHttpTxnCachedRespGet(txnp, &bufp, &hdr_loc)) {
+ return 0;
+ }
}
+
resp_status = TSHttpHdrStatusGet(bufp, hdr_loc);
- TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
// conservatively pick some statusses to compress
if (!(resp_status == 200 || resp_status == 404 || resp_status == 500)) {
info("http response status [%d] is not compressible", resp_status);
+ TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
return 0;
}
if (TS_SUCCESS != TSHttpTxnClientReqGet(txnp, &cbuf, &chdr)) {
info("cound not get client request");
+ TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
return 0;
}
@@ -526,27 +532,17 @@ gzip_transformable(TSHttpTxn txnp, bool server, HostConfiguration *host_configur
if (!compression_acceptable) {
info("no acceptable encoding found in request header, not compressible");
+ TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
return 0;
}
} else {
info("no acceptable encoding found in request header, not compressible");
TSHandleMLocRelease(cbuf, chdr, cfield);
TSHandleMLocRelease(cbuf, TS_NULL_MLOC, chdr);
+ TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
return 0;
}
- if (server) {
- if (TS_SUCCESS != TSHttpTxnServerRespGet(txnp, &bufp, &hdr_loc)) {
- info("could not get server response");
- return 0;
- }
- } else {
- if (TS_SUCCESS != TSHttpTxnCachedRespGet(txnp, &bufp, &hdr_loc)) {
- info("could not get cached response");
- return 0;
- }
- }
-
/* If there already exists a content encoding then we don't want
to do anything. */
field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, TS_MIME_FIELD_CONTENT_ENCODING, -1);
@@ -569,11 +565,14 @@ gzip_transformable(TSHttpTxn txnp, bool server, HostConfiguration *host_configur
value = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, -1, &len);
int rv = host_configuration->is_content_type_compressible(value, len);
+
if (!rv) {
info("content-type [%.*s] not compressible", len, value);
}
+
TSHandleMLocRelease(bufp, hdr_loc, field_loc);
TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
+
return rv;
}