Fix coverity defect 75/178075/1 accepted/tizen/unified/20180508.134803 submit/tizen/20180508.050430
authorDongsun Lee <ds73.lee@samsung.com>
Tue, 8 May 2018 04:56:48 +0000 (13:56 +0900)
committerDongsun Lee <ds73.lee@samsung.com>
Tue, 8 May 2018 04:56:54 +0000 (13:56 +0900)
- 120541 : improper use of nagative value

Change-Id: Ic93d890a08def810a8f09ed6bbb8171e440438df
Signed-off-by: Dongsun Lee <ds73.lee@samsung.com>
src/manager/common/openssl-error-handler.cpp

index cac3834..40c3d2b 100644 (file)
@@ -60,9 +60,14 @@ void errorDump()
        BIO *bio = BIO_new(BIO_s_mem());
        ERR_print_errors(bio);
        char *buf = NULL;
-       size_t len = BIO_get_mem_data(bio, &buf);
+       long len = BIO_get_mem_data(bio, &buf);
+       if(len < 0) {
+               LogError("Fail in BIO_get_mem_data()");
+               return;
+       }
+       size_t length = static_cast<size_t>(len);
        BIO_free(bio);
-       std::string ret(buf, len);
+       std::string ret(buf, length);
        free(buf);
        LogError(ret);
 }
@@ -190,4 +195,4 @@ void errorHandle(const char *file, int line, const char *function, int openssl_r
 
 }
 
-} // namespace CKM
\ No newline at end of file
+} // namespace CKM