@@ -226,14 +226,14 @@ bool Rbl::evaluate(Transaction *t, RuleWithActions *rule,
226
226
return false ;
227
227
}
228
228
229
- // NOSONAR
230
229
// SonarCloud suggested to use the init-statement to declare "addr" inside the if statement.
231
230
// I think that's not good here, because we need that in the else block
232
- struct sockaddr *addr = info->ai_addr ;
233
- // NOSONAR
234
- if (addr->sa_family == AF_INET) { // only IPv4 address is allowed
235
- auto sin = (struct sockaddr_in *) addr; // cppcheck-suppress[dangerousTypeCast]
236
- furtherInfo (sin, ipStr, t, m_provider);
231
+ struct sockaddr *addr = info->ai_addr ; // NOSONAR
232
+ if (addr->sa_family == AF_INET) { // NOSONAR
233
+ struct sockaddr_in sin{}; // initialize an empty struct; we don't need port info
234
+ memcpy (&sin.sin_addr , addr->sa_data + 2 , sizeof (sin.sin_addr ));
235
+ sin.sin_family = AF_INET;
236
+ furtherInfo (&sin, ipStr, t, m_provider);
237
237
}
238
238
else {
239
239
ms_dbg_a (t, 7 , " Unsupported address family: " + std::to_string (addr->sa_family ));
0 commit comments