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 2017/05/09 19:04:30 UTC
[trafficserver] branch 7.1.x updated: Coverity 1200018 & 1200017
This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch 7.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/7.1.x by this push:
new ae69141 Coverity 1200018 & 1200017
ae69141 is described below
commit ae69141ad23be9c93d75b52f6f32dbd6ada1ecdd
Author: Gancho Tenev <ga...@apache.com>
AuthorDate: Tue May 9 11:26:46 2017 -0700
Coverity 1200018 & 1200017
Problem:
CID 1200018 (#1 of 1): Resource leak (RESOURCE_LEAK)
13. overwrite_var: Overwriting token in token = _TSstrdup(val, -1L, "memory/secure-link/secure-link.c:70") leaks the storage that token points to.
CID 1200017 (#1 of 1): Resource leak (RESOURCE_LEAK)
19. overwrite_var: Overwriting expire in expire = _TSstrdup(val, -1L, "memory/secure-link/secure-link.c:72") leaks the storage that expire points to
Fix:
Took the TSstrdup() for expire and token outside the loop to avoid the leak.
(cherry picked from commit da948249f541812a5d6fea6cd93fed45ea1ad52f)
---
example/secure-link/secure-link.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/example/secure-link/secure-link.c b/example/secure-link/secure-link.c
index 7837bf1..d2b691a 100644
--- a/example/secure-link/secure-link.c
+++ b/example/secure-link/secure-link.c
@@ -50,7 +50,7 @@ TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
const char *qh, *ph, *ip;
unsigned char md[MD5_DIGEST_LENGTH];
secure_link_info *sli = (secure_link_info *)ih;
- char *token = NULL, *expire = NULL, *path = NULL;
+ char *token = NULL, *tokenptr = NULL, *expire = NULL, *expireptr = NULL, *path = NULL;
char *s, *ptr, *saveptr = NULL, *val, hash[32] = "";
in = (struct sockaddr_in *)TSHttpTxnClientAddrGet(rh);
@@ -67,15 +67,17 @@ TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
if ((val = strchr(ptr, '=')) != NULL) {
*val++ = '\0';
if (strcmp(ptr, "st") == 0) {
- token = TSstrdup(val);
+ tokenptr = val;
} else if (strcmp(ptr, "ex") == 0) {
- expire = TSstrdup(val);
+ expireptr = val;
}
} else {
TSError("[secure_link] Invalid parameter [%s]", ptr);
break;
}
} while ((ptr = strtok_r(NULL, "&", &saveptr)) != NULL);
+ token = (NULL == tokenptr ? NULL : TSstrdup(tokenptr));
+ expire = (NULL == expireptr ? NULL : TSstrdup(expireptr));
} else {
TSError("[secure_link] strtok didn't find a & in the query string");
/* this is just example, so set fake params to prevent plugin crash */
--
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].