This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 06e0ba0116 Check the inet_pton return value for IP reputations (#10267)
06e0ba0116 is described below
commit 06e0ba0116188a85a89b930cd92176d9386c3213
Author: Leif Hedstrom <[email protected]>
AuthorDate: Mon Aug 28 16:12:19 2023 -0600
Check the inet_pton return value for IP reputations (#10267)
This fixes #10223.
---
plugins/experimental/rate_limit/ip_reputation.cc | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/plugins/experimental/rate_limit/ip_reputation.cc
b/plugins/experimental/rate_limit/ip_reputation.cc
index 9f6d9b59bd..764093e775 100644
--- a/plugins/experimental/rate_limit/ip_reputation.cc
+++ b/plugins/experimental/rate_limit/ip_reputation.cc
@@ -58,21 +58,24 @@ SieveLru::hasher(const std::string &ip, u_short family) //
Mostly a convenience
case AF_INET: {
sockaddr_in sa4;
- inet_pton(AF_INET, ip.c_str(), &(sa4.sin_addr));
- sa4.sin_family = AF_INET;
- return hasher(reinterpret_cast<const sockaddr *>(&sa4));
+ if (inet_pton(AF_INET, ip.c_str(), &(sa4.sin_addr))) {
+ sa4.sin_family = AF_INET;
+ return hasher(reinterpret_cast<const sockaddr *>(&sa4));
+ }
} break;
case AF_INET6: {
sockaddr_in6 sa6;
- inet_pton(AF_INET6, ip.c_str(), &(sa6.sin6_addr));
- sa6.sin6_family = AF_INET6;
- return hasher(reinterpret_cast<const sockaddr *>(&sa6));
+ if (inet_pton(AF_INET6, ip.c_str(), &(sa6.sin6_addr))) {
+ sa6.sin6_family = AF_INET6;
+ return hasher(reinterpret_cast<const sockaddr *>(&sa6));
+ }
} break;
default:
- // Really shouldn't happen ...
- return 0;
+ break;
}
+
+ return 0; // Probably can't happen, but have to return something
}
// Constructor, setting up the pre-sized LRU buckets etc.
SieveLru::SieveLru(uint32_t num_buckets, uint32_t size) :
_lock(TSMutexCreate())