mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-16 07:56:12 +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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOSONAR
|
|
||||||
// SonarCloud suggested to use the init-statement to declare "addr" inside the if statement.
|
// 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
|
// I think that's not good here, because we need that in the else block
|
||||||
struct sockaddr *addr = info->ai_addr;
|
struct sockaddr *addr = info->ai_addr; // NOSONAR
|
||||||
// NOSONAR
|
if (addr->sa_family == AF_INET) { // NOSONAR
|
||||||
if (addr->sa_family == AF_INET) { // only IPv4 address is allowed
|
struct sockaddr_in sin{}; // initialize an empty struct; we don't need port info
|
||||||
auto sin = (struct sockaddr_in *) addr; // cppcheck-suppress[dangerousTypeCast]
|
memcpy(&sin.sin_addr, addr->sa_data + 2, sizeof(sin.sin_addr));
|
||||||
furtherInfo(sin, ipStr, t, m_provider);
|
sin.sin_family = AF_INET;
|
||||||
|
furtherInfo(&sin, ipStr, t, m_provider);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ms_dbg_a(t, 7, "Unsupported address family: " + std::to_string(addr->sa_family));
|
ms_dbg_a(t, 7, "Unsupported address family: " + std::to_string(addr->sa_family));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user