mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Try to avoid any kind of type casting
This commit is contained in:
parent
e879711d87
commit
8b3269f4d1
@ -226,14 +226,14 @@ bool Rbl::evaluate(Transaction *t, RuleWithActions *rule,
|
||||
return false;
|
||||
}
|
||||
|
||||
// NOSONAR
|
||||
// SonarCloud suggested to use the init-statement to declare "addr" inside the if statement.
|
||||
// I think that's not good here, because we need that in the else block
|
||||
struct sockaddr *addr = info->ai_addr;
|
||||
// NOSONAR
|
||||
if (addr->sa_family == AF_INET) { // only IPv4 address is allowed
|
||||
auto sin = (struct sockaddr_in *) addr; // cppcheck-suppress[dangerousTypeCast]
|
||||
furtherInfo(sin, ipStr, t, m_provider);
|
||||
struct sockaddr *addr = info->ai_addr; // NOSONAR
|
||||
if (addr->sa_family == AF_INET) { // NOSONAR
|
||||
struct sockaddr_in sin{}; // initialize an empty struct; we don't need port info
|
||||
memcpy(&sin.sin_addr, addr->sa_data + 2, sizeof(sin.sin_addr));
|
||||
sin.sin_family = AF_INET;
|
||||
furtherInfo(&sin, ipStr, t, m_provider);
|
||||
}
|
||||
else {
|
||||
ms_dbg_a(t, 7, "Unsupported address family: " + std::to_string(addr->sa_family));
|
||||
|
Loading…
x
Reference in New Issue
Block a user