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 2018/02/22 04:56:18 UTC

[trafficserver] 02/02: Fixed several memory leaks inside the uri_signing plugin.

This is an automated email from the ASF dual-hosted git repository.

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

commit 0cb904fdea10393561be456dbffb80186a737d07
Author: Chris Lemmons <ch...@comcast.com>
AuthorDate: Wed Feb 21 23:13:41 2018 +0000

    Fixed several memory leaks inside the uri_signing plugin.
    
    Co-authored-by: Jeff Elsloo <je...@cable.comcast.com>
    Co-authored-by: Evan Zelkowitz <ev...@comcast.com>
---
 plugins/experimental/uri_signing/uri_signing.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/plugins/experimental/uri_signing/uri_signing.c b/plugins/experimental/uri_signing/uri_signing.c
index 0d81541..9338662 100644
--- a/plugins/experimental/uri_signing/uri_signing.c
+++ b/plugins/experimental/uri_signing/uri_signing.c
@@ -106,7 +106,7 @@ add_cookie(TSCont cont, TSEvent event, void *edata)
   }
 
   if (TSMimeHdrFieldCreateNamed(buffer, hdr, "Set-Cookie", 10, &field) != TS_SUCCESS) {
-    goto fail;
+    goto fail_hdr;
   }
 
   if (TSMimeHdrFieldAppend(buffer, hdr, field) != TS_SUCCESS) {
@@ -121,6 +121,8 @@ add_cookie(TSCont cont, TSEvent event, void *edata)
 
 fail_field:
   TSHandleMLocRelease(buffer, hdr, field);
+fail_hdr:
+  TSHandleMLocRelease(buffer, TS_NULL_MLOC, hdr);
 fail:
   free(cookie);
   TSContDestroy(cont);
@@ -167,8 +169,9 @@ TSRemapDoRemap(void *ih, TSHttpTxn txnp, TSRemapRequestInfo *rri)
   }
   url = TSUrlStringGet(mbuf, ul, &url_ct);
 
-  PluginDebug("Processing request for %.*s.", url_ct, url);
+  TSHandleMLocRelease(mbuf, TS_NULL_MLOC, ul);
 
+  PluginDebug("Processing request for %.*s.", url_ct, url);
   if (cpi < max_cpi) {
     checkpoints[cpi++] = mark_timer(&t);
   }
@@ -191,12 +194,17 @@ TSRemapDoRemap(void *ih, TSHttpTxn txnp, TSRemapRequestInfo *rri)
 
     field = TSMimeHdrFieldFind(buffer, hdr, "Cookie", 6);
     if (field == TS_NULL_MLOC) {
+      TSHandleMLocRelease(buffer, TS_NULL_MLOC, hdr);
       goto fail;
     }
 
     const char *client_cookie;
     int client_cookie_ct;
     client_cookie = TSMimeHdrFieldValueStringGet(buffer, hdr, field, 0, &client_cookie_ct);
+
+    TSHandleMLocRelease(buffer, hdr, field);
+    TSHandleMLocRelease(buffer, TS_NULL_MLOC, hdr);
+
     if (!client_cookie || !client_cookie_ct) {
       goto fail;
     }
@@ -210,10 +218,12 @@ TSRemapDoRemap(void *ih, TSHttpTxn txnp, TSRemapRequestInfo *rri)
   if (!jws) {
     goto fail;
   }
+
   if (cpi < max_cpi) {
     checkpoints[cpi++] = mark_timer(&t);
   }
   struct jwt *jwt = validate_jws(jws, (struct config *)ih, url, url_ct);
+  cjose_jws_release(jws);
   if (cpi < max_cpi) {
     checkpoints[cpi++] = mark_timer(&t);
   }
@@ -227,6 +237,8 @@ TSRemapDoRemap(void *ih, TSHttpTxn txnp, TSRemapRequestInfo *rri)
 
   struct signer *signer = config_signer((struct config *)ih);
   char *cookie          = renew(jwt, signer->issuer, signer->jwk, signer->alg, package);
+  jwt_delete(jwt);
+
   if (cpi < max_cpi) {
     checkpoints[cpi++] = mark_timer(&t);
   }

-- 
To stop receiving notification emails like this one, please contact
sorber@apache.org.