]> granicus.if.org Git - pdns/commitdiff
XPF: Fix coverity "copy paste" issue
authorPieter Lexis <pieter.lexis@powerdns.com>
Wed, 24 Jan 2018 09:06:33 +0000 (10:06 +0100)
committerPieter Lexis <pieter.lexis@powerdns.com>
Wed, 24 Jan 2018 09:24:07 +0000 (10:24 +0100)
Fix CID 1385372.

pdns/xpf.cc

index 86d98d75f206677604e73f693aae3037e7946fb2..270428b4f1469849938fc891edc163ccfbb77eff 100644 (file)
@@ -40,20 +40,16 @@ std::string generateXPFPayload(bool tcp, const ComboAddress& source, const Combo
   ret.append(reinterpret_cast<const char*>(&version), sizeof(version));
   ret.append(reinterpret_cast<const char*>(&protocol), sizeof(protocol));
 
+  // We already established source and destination sin_family equivalence
   if (source.isIPv4()) {
     assert(addrSize == sizeof(source.sin4.sin_addr.s_addr));
     ret.append(reinterpret_cast<const char*>(&source.sin4.sin_addr.s_addr), addrSize);
-  }
-  else {
-    assert(addrSize == sizeof(source.sin6.sin6_addr.s6_addr));
-    ret.append(reinterpret_cast<const char*>(&source.sin6.sin6_addr.s6_addr), addrSize);
-  }
-
-  if (source.isIPv4()) {
     assert(addrSize == sizeof(destination.sin4.sin_addr.s_addr));
     ret.append(reinterpret_cast<const char*>(&destination.sin4.sin_addr.s_addr), addrSize);
   }
   else {
+    assert(addrSize == sizeof(source.sin6.sin6_addr.s6_addr));
+    ret.append(reinterpret_cast<const char*>(&source.sin6.sin6_addr.s6_addr), addrSize);
     assert(addrSize == sizeof(destination.sin6.sin6_addr.s6_addr));
     ret.append(reinterpret_cast<const char*>(&destination.sin6.sin6_addr.s6_addr), addrSize);
   }