1 /* 2 * Copyright (c) 2025-2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #include "profile_info.h" 16 #include "securec.h" 17 #include "signature_tools_log.h" 18 19 namespace OHOS { 20 namespace SignatureTools { 21 ProfileInfo()22ProfileInfo::ProfileInfo() 23 { 24 profileBlock = nullptr; 25 } ~ProfileInfo()26ProfileInfo::~ProfileInfo() 27 { 28 profileBlock.reset(nullptr); 29 } ProfileInfo(const ProfileInfo & profileInfo)30ProfileInfo::ProfileInfo(const ProfileInfo& profileInfo) 31 { 32 *this = profileInfo; 33 } operator =(const ProfileInfo & profileInfo)34ProfileInfo& ProfileInfo::operator=(const ProfileInfo& profileInfo) 35 { 36 if (this == &profileInfo) { 37 return *this; 38 } 39 this->versionCode = profileInfo.versionCode; 40 this->versionName = profileInfo.versionName; 41 this->uuid = profileInfo.uuid; 42 this->type = profileInfo.type; 43 this->distributionType = profileInfo.distributionType; 44 this->bundleInfo = profileInfo.bundleInfo; 45 this->acls = profileInfo.acls; 46 this->permissions = profileInfo.permissions; 47 this->debugInfo = profileInfo.debugInfo; 48 this->issuer = profileInfo.issuer; 49 this->appId = profileInfo.appId; 50 this->fingerprint = profileInfo.fingerprint; 51 this->appPrivilegeCapabilities = profileInfo.appPrivilegeCapabilities; 52 this->validity = profileInfo.validity; 53 this->metadatas = profileInfo.metadatas; 54 this->profileBlockLength = profileInfo.profileBlockLength; 55 (this->profileBlock).reset(nullptr); 56 if (profileInfo.profileBlockLength != 0 && profileInfo.profileBlock != nullptr) { 57 this->profileBlock = std::make_unique<unsigned char[]>(profileInfo.profileBlockLength); 58 unsigned char* profileBlockData = (this->profileBlock).get(); 59 unsigned char* originalProfile = profileInfo.profileBlock.get(); 60 if (profileBlockData == nullptr) { 61 return *this; 62 } 63 std::copy(originalProfile, originalProfile + profileInfo.profileBlockLength, profileBlockData); 64 } 65 this->appServiceCapabilities = profileInfo.appServiceCapabilities; 66 this->organization = profileInfo.organization; 67 return *this; 68 } 69 } // namespace SignatureTools 70 } // namespace OHOS