]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[(no branch, rebasing 1909-gss_tsig-hook)] [#1909] Fixed Coverity complain about...
authorFrancis Dupont <fdupont@isc.org>
Tue, 8 Jun 2021 20:35:37 +0000 (22:35 +0200)
committerFrancis Dupont <fdupont@isc.org>
Sat, 12 Jun 2021 16:34:42 +0000 (18:34 +0200)
src/lib/dns/rdata/generic/tkey_249.cc
src/lib/dns/rdataclass.cc

index 886eb40375b4b60c17ffb16e6af4af0d32f92646..435a345ac5a86d7c86f20994ef49afcaec9eb595 100644 (file)
@@ -69,10 +69,15 @@ struct TKEYImpl {
              const void* key, size_t other_len, const void* other_data) :
         algorithm_(algorithm), inception_(inception), expire_(expire),
         mode_(mode), error_(error),
-        key_(static_cast<const uint8_t*>(key),
-             static_cast<const uint8_t*>(key) + key_len),
-        other_data_(static_cast<const uint8_t*>(other_data),
-                    static_cast<const uint8_t*>(other_data) + other_len)
+        key_(key_len > 0 ?
+             vector<uint8_t>(static_cast<const uint8_t*>(key),
+                             static_cast<const uint8_t*>(key) + key_len) :
+             vector<uint8_t>(key_len)),
+        other_data_(other_len > 0 ?
+                    vector<uint8_t>(static_cast<const uint8_t*>(other_data),
+                                    static_cast<const uint8_t*>(other_data) +
+                                    other_len) :
+                    vector<uint8_t>(other_len))
     {}
 
     /// \brief Common part of toWire methods.
index 3a3de4aa330e1c30ab16760a14eab4180e6ac84e..3cb61ade93bcd322cc796e51415e03cd04087fa0 100644 (file)
@@ -5217,10 +5217,15 @@ struct TKEYImpl {
              const void* key, size_t other_len, const void* other_data) :
         algorithm_(algorithm), inception_(inception), expire_(expire),
         mode_(mode), error_(error),
-        key_(static_cast<const uint8_t*>(key),
-             static_cast<const uint8_t*>(key) + key_len),
-        other_data_(static_cast<const uint8_t*>(other_data),
-                    static_cast<const uint8_t*>(other_data) + other_len)
+        key_(key_len > 0 ?
+             vector<uint8_t>(static_cast<const uint8_t*>(key),
+                             static_cast<const uint8_t*>(key) + key_len) :
+             vector<uint8_t>(key_len)),
+        other_data_(other_len > 0 ?
+                    vector<uint8_t>(static_cast<const uint8_t*>(other_data),
+                                    static_cast<const uint8_t*>(other_data) +
+                                    other_len) :
+                    vector<uint8_t>(other_len))
     {}
 
     /// \brief Common part of toWire methods.