Fix coverity defect 27/225027/3 accepted/tizen_unified tizen accepted/tizen/unified/20200218.145930 submit/tizen/20200217.042237
authorSangwan Kwon <sangwan.kwon@samsung.com>
Mon, 17 Feb 2020 01:00:02 +0000 (10:00 +0900)
committerSangwan Kwon <sangwan.kwon@samsung.com>
Mon, 17 Feb 2020 02:28:00 +0000 (11:28 +0900)
- Incorrect deallocator used
- Bad bit shift operation

Change-Id: I2ea1f33da459ee62883be6038dfd7268d2782558
Signed-off-by: Sangwan Kwon <sangwan.kwon@samsung.com>
src/common/net/http/transport_security_state.cpp
src/curl/tpkp_curl.cpp

index d3b5db525904c9987b6412e3f1fa6feb12181bb3..9703f2df0b0459b5d6ca00ad0d9e0ff14bc3dda2 100644 (file)
@@ -30,6 +30,8 @@
 
 // This file is subset of chromium-efl/net/http/transport_security_state.cc
 
+#include <stdexcept>
+
 #include "net/http/transport_security_state.h"
 #include "net/http/transport_security_state_static.h"
 #include "base/logging.h"
@@ -68,6 +70,8 @@ class BitReader {
   // insufficient bits in the input or true otherwise.
   bool Read(unsigned num_bits, uint32* out) {
     DCHECK_LE(num_bits, 32u);
+    if (num_bits > 32u)
+      throw std::invalid_argument("num_bits should be less equal than 32u.");
 
     uint32 ret = 0;
     for (unsigned i = 0; i < num_bits; ++i) {
index 2e7dd0a2c48635f33b8ac577634ae5b53b68804c..5982754ed64f77d0e011eabdffdffd28bbf67fbf 100644 (file)
@@ -69,7 +69,7 @@ TPKP::RawBuffer getPubkeyHash(X509 *cert, TPKP::HashAlgo algo)
                TPKP_E_INVALID_CERT, "Failed to convert pem pubkey to der.");
 
        TPKP::RawBuffer pubkeyder(der, der + len);
-       free(der);
+       OPENSSL_free(der);
        unsigned char *hashResult = nullptr;
        TPKP::RawBuffer out;
        switch (algo) {