You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by ne...@apache.org on 2020/04/30 16:11:47 UTC
[trafficcontrol] branch master updated: Astats plugin - Add null
check around strtok_r token usage (#4531)
This is an automated email from the ASF dual-hosted git repository.
neuman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new 180e4d9 Astats plugin - Add null check around strtok_r token usage (#4531)
180e4d9 is described below
commit 180e4d99ad2cf0b938d6344e159111f79a759536
Author: Evan Zelkowitz <ez...@apache.org>
AuthorDate: Thu Apr 30 09:11:40 2020 -0700
Astats plugin - Add null check around strtok_r token usage (#4531)
* Add null check around strtok_r token usage. According to clang analyzer its possible that the token might be null, which you cannot pass to strtok_r as the save pointer (last argument). Adding a null check before calling those
* Add changelog entry
---
CHANGELOG.md | 1 +
traffic_server/plugins/astats_over_http/astats_over_http.c | 12 ++++++++++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 369fbeb..9e84d14 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -50,6 +50,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- /api/2.0/snapshot `PUT`
### Changed
+- Add null check in astats plugin before calling strtok to find ip mask values in the config file
- Fix to traffic_ops_ort.pl to strip specific comment lines before checking if a file has changed. Also promoted a changed file message from DEBUG to ERROR for report mode.
- Fixed Traffic Portal regenerating CDN DNSSEC keys with the wrong effective date
- Fixed issue #4583: POST /users/register internal server error caused by failing DB query
diff --git a/traffic_server/plugins/astats_over_http/astats_over_http.c b/traffic_server/plugins/astats_over_http/astats_over_http.c
index 58b8121..e39bcc8 100644
--- a/traffic_server/plugins/astats_over_http/astats_over_http.c
+++ b/traffic_server/plugins/astats_over_http/astats_over_http.c
@@ -599,7 +599,11 @@ static void parseIps(config_t* config, char* ipStr) {
TSDebug(PLUGIN_TAG, "%d) skipping: %s", i+1,tok1);
continue;
}
- tok2 = strtok_r(tok1, "/", &tok1);
+
+ if (tok1 != NULL) {
+ tok2 = strtok_r(tok1, "/", &tok1);
+ }
+
if(!tok2) {
mask = 32;
} else {
@@ -646,7 +650,11 @@ static void parseIps6(config_t* config, char* ipStr) {
TSDebug(PLUGIN_TAG, "%d) skipping: %s", i+1,tok1);
continue;
}
- tok2 = strtok_r(tok1, "/", &tok1);
+
+ if (tok1 != NULL) {
+ tok2 = strtok_r(tok1, "/", &tok1);
+ }
+
if(!tok2) {
mask = 128;
} else {