Fix out of bound access 44/167444/1
authorBartlomiej Grzelewski <b.grzelewski@samsung.com>
Wed, 17 Jan 2018 15:21:28 +0000 (16:21 +0100)
committerBartlomiej Grzelewski <b.grzelewski@samsung.com>
Wed, 17 Jan 2018 15:24:52 +0000 (16:24 +0100)
Change-Id: I830cdc82351b18a670c4950a720f18433532a966

src/manager/common/key-impl.cpp

index 680f7e1..2a12818 100644 (file)
@@ -91,6 +91,13 @@ KeyImpl::KeyImpl(const RawBuffer &buf, const Password &password) :
 {
        bool isPrivate = false;
        EVP_PKEY *pkey = nullptr;
+
+       if (buf.empty()) {
+               /* We need at least one byte to continue parsing... */
+               LogError("Failed to parse key - empty buffer found!");
+               return;
+       }
+
        BioUniquePtr bio(BIO_new(BIO_s_mem()), BIO_free_all);
 
        LogDebug("Start to parse key:");