gpt4 book ai didi

java - 防御性复制帮助-数组直接存储-影响分析

转载 作者:行者123 更新时间:2023-12-01 11:11:01 25 4
gpt4 key购买 nike

我修复了一个 Sonar 安全警报 - 数组直接存储

最初

void setDerivedKey(byte[] derivedKey)
{
this.derivedKey = derivedKey;
}

void setDerivedKey (byte[] newDerivedKey)
{
if(newDerivedKey==null)
{ this.derivedKey = new byte[0]; }
else
{ this.derivedKey = Arrays.copyOf(newDerivedKey, newDerivedKey.length); }
}

如何解决这个问题

    public pEngine(byte[] salt) {
byte[] mySalt = Arrays.copyOf(salt, salt.length); //Edited as per below answer
this.parameters = new pParameters("SomeValue", "SomeValue2", salt, 100); }

修复的影响是什么

 Performance
Memory management
Functionality

最佳答案

我不确定我是否理解。为什么不:

public pEngine(byte[] salt) {
byte[] mySalt = Arrays.copyOf(salt, salt.length);
this.parameters = new pParameters("SomeValue", "SomeValue2", mySalt, 100);
}

关于java - 防御性复制帮助-数组直接存储-影响分析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32374805/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com