Add minor fixes for listing aliases from db 93/207393/3
authorTomasz Swierczek <t.swierczek@samsung.com>
Tue, 4 Jun 2019 06:55:09 +0000 (08:55 +0200)
committerTomasz Swierczek <t.swierczek@samsung.com>
Wed, 5 Jun 2019 09:32:45 +0000 (11:32 +0200)
* update list out pointer to null if there are no aliases to list

This is in accordance to official header documentation; in such case, the code
returns CKMC_ERROR_DB_ALIAS_UNKNOWN but also the list should be properly null'ed.

Change-Id: I2861e67ae80fe0ce73b0e2e180aba393f66e255c

src/manager/client-capi/ckmc-manager.cpp

index a765f3a..970fed5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2000 - 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2000-2019 Samsung Electronics Co., Ltd. All rights reserved
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -213,8 +213,10 @@ int _toNewCkmcAliasInfoList(const CKM::AliasPwdVector &aliasPwdVector,
        if (alias_info_list == nullptr)
                return CKMC_ERROR_UNKNOWN;
 
-       if (aliasPwdVector.size() == 0)
+       if (aliasPwdVector.size() == 0) {
+               *alias_info_list = nullptr; // according to documentation from header
                return CKMC_ERROR_DB_ALIAS_UNKNOWN;
+    }
 
        ckmc_alias_info_list_s *start = nullptr;
        ckmc_alias_info_list_s *plist = nullptr;
@@ -387,11 +389,11 @@ int ckmc_get_key_alias_list(ckmc_alias_list_s **alias_list)
                        start = plist;
        }
 
+       *alias_list = start; // according to documentation in header
+
        if (plist == nullptr) // if the alias_list size is zero
                return CKMC_ERROR_DB_ALIAS_UNKNOWN;
 
-       *alias_list = start;
-
        return CKMC_ERROR_NONE;
 
        EXCEPTION_GUARD_END
@@ -490,11 +492,11 @@ int ckmc_get_cert_alias_list(ckmc_alias_list_s **alias_list)
                        start = plist;
        }
 
+       *alias_list = start; // according to documentation from header
+
        if (plist == nullptr) // if the alias_list size is zero
                return CKMC_ERROR_DB_ALIAS_UNKNOWN;
 
-       *alias_list = start;
-
        return CKMC_ERROR_NONE;
 
        EXCEPTION_GUARD_END
@@ -687,11 +689,11 @@ int ckmc_get_data_alias_list(ckmc_alias_list_s **alias_list)
                        start = plist;
        }
 
+       *alias_list = start; // according to documentation in header
+
        if (plist == nullptr) // if the alias_list size is zero
                return CKMC_ERROR_DB_ALIAS_UNKNOWN;
 
-       *alias_list = start;
-
        return CKMC_ERROR_NONE;
 
        EXCEPTION_GUARD_END