From d5d68f6182d787d56ecdaae7734ccecea20f56f0 Mon Sep 17 00:00:00 2001 From: Francis Dupont Date: Tue, 8 Jun 2021 22:35:37 +0200 Subject: [PATCH] [(no branch, rebasing 1909-gss_tsig-hook)] [#1909] Fixed Coverity complain about TKEY second constructor --- src/lib/dns/rdata/generic/tkey_249.cc | 13 +++++++++---- src/lib/dns/rdataclass.cc | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/lib/dns/rdata/generic/tkey_249.cc b/src/lib/dns/rdata/generic/tkey_249.cc index 886eb40375..435a345ac5 100644 --- a/src/lib/dns/rdata/generic/tkey_249.cc +++ b/src/lib/dns/rdata/generic/tkey_249.cc @@ -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(key), - static_cast(key) + key_len), - other_data_(static_cast(other_data), - static_cast(other_data) + other_len) + key_(key_len > 0 ? + vector(static_cast(key), + static_cast(key) + key_len) : + vector(key_len)), + other_data_(other_len > 0 ? + vector(static_cast(other_data), + static_cast(other_data) + + other_len) : + vector(other_len)) {} /// \brief Common part of toWire methods. diff --git a/src/lib/dns/rdataclass.cc b/src/lib/dns/rdataclass.cc index 3a3de4aa33..3cb61ade93 100644 --- a/src/lib/dns/rdataclass.cc +++ b/src/lib/dns/rdataclass.cc @@ -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(key), - static_cast(key) + key_len), - other_data_(static_cast(other_data), - static_cast(other_data) + other_len) + key_(key_len > 0 ? + vector(static_cast(key), + static_cast(key) + key_len) : + vector(key_len)), + other_data_(other_len > 0 ? + vector(static_cast(other_data), + static_cast(other_data) + + other_len) : + vector(other_len)) {} /// \brief Common part of toWire methods.