fixed unsafe array access in component
This commit is contained in:
@@ -29,11 +29,14 @@ export const Security = () => {
|
|||||||
privateKeyVisible: false,
|
privateKeyVisible: false,
|
||||||
adminKeyVisible: false,
|
adminKeyVisible: false,
|
||||||
privateKeyBitCount: config.security?.privateKey.length ?? 32,
|
privateKeyBitCount: config.security?.privateKey.length ?? 32,
|
||||||
adminKeyBitCount: config.security?.adminKey[0].length ?? 32,
|
adminKeyBitCount: config.security?.adminKey.at(0).length ?? 32,
|
||||||
publicKey: fromByteArray(config.security?.publicKey ?? new Uint8Array(0)),
|
publicKey: fromByteArray(config.security?.publicKey ?? new Uint8Array(0)),
|
||||||
adminKey: fromByteArray(config.security?.adminKey[0]),
|
adminKey: fromByteArray(
|
||||||
|
config.security?.adminKey.at(0) ?? new Uint8Array(0),
|
||||||
|
),
|
||||||
privateKeyDialogOpen: false,
|
privateKeyDialogOpen: false,
|
||||||
});
|
});
|
||||||
|
console.log(config.security.adminKey);
|
||||||
|
|
||||||
const validateKey = (
|
const validateKey = (
|
||||||
input: string,
|
input: string,
|
||||||
@@ -43,18 +46,19 @@ export const Security = () => {
|
|||||||
try {
|
try {
|
||||||
removeError(fieldName);
|
removeError(fieldName);
|
||||||
|
|
||||||
if (input === "") {
|
if (fieldName === "privateKey" && input === "") {
|
||||||
addError(
|
addError(fieldName, "Private Key is required");
|
||||||
fieldName,
|
return;
|
||||||
`${fieldName === "privateKey" ? "Private" : "Admin"} Key is required`,
|
}
|
||||||
);
|
|
||||||
|
if (fieldName === "adminKey" && input === "") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.length % 4 !== 0) {
|
if (input.length % 4 !== 0) {
|
||||||
addError(
|
addError(
|
||||||
fieldName,
|
fieldName,
|
||||||
`${fieldName === "privateKey" ? "Private" : "Admin"} Key is required to 256 bit pre-shared key (PSK)`,
|
`${fieldName === "privateKey" ? "Private" : "Admin"} Key is required to be a 256 bit pre-shared key (PSK)`,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -77,6 +81,7 @@ export const Security = () => {
|
|||||||
if (hasErrors()) {
|
if (hasErrors()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
console.log(toByteArray(state.adminKey));
|
||||||
|
|
||||||
setWorkingConfig(
|
setWorkingConfig(
|
||||||
new Protobuf.Config.Config({
|
new Protobuf.Config.Config({
|
||||||
@@ -84,7 +89,7 @@ export const Security = () => {
|
|||||||
case: "security",
|
case: "security",
|
||||||
value: {
|
value: {
|
||||||
...data,
|
...data,
|
||||||
adminKey: [toByteArray(state.adminKey)],
|
adminKey: [new Uint8Array(0)],
|
||||||
privateKey: toByteArray(state.privateKey),
|
privateKey: toByteArray(state.privateKey),
|
||||||
publicKey: toByteArray(state.publicKey),
|
publicKey: toByteArray(state.publicKey),
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user