Ghidra is a software reverse engineering (SRE) framework
GP-7261 Added DB parameter size checking
ghidra10522a776a23c
diff --git a/Ghidra/Framework/DB/src/main/java/db/buffers/BufferFile.java b/Ghidra/Framework/DB/src/main/java/db/buffers/BufferFile.javaindex 60017ed585..46ed14eb17 100644--- a/Ghidra/Framework/DB/src/main/java/db/buffers/BufferFile.java+++ b/Ghidra/Framework/DB/src/main/java/db/buffers/BufferFile.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -25,6 +25,8 @@ import java.util.NoSuchElementException;*/public interface BufferFile {+ public static final int MAX_PARAM_NAME_LENGTH = 40;+/*** Returns true if this file may not be modified* via the buffer put method.@@ -55,7 +57,7 @@ public interface BufferFile {/*** Set the integer value for a named parameter.- * @param name parameter name+ * @param name parameter name (encoded length may not exceed {@value #MAX_PARAM_NAME_LENGTH}-bytes)* @param value parameter value* @throws IOException*/diff --git a/Ghidra/Framework/DB/src/main/java/db/buffers/LocalBufferFile.java b/Ghidra/Framework/DB/src/main/java/db/buffers/LocalBufferFile.javaindex 0e4fb7d365..4d1bc47f7e 100644--- a/Ghidra/Framework/DB/src/main/java/db/buffers/LocalBufferFile.java+++ b/Ghidra/Framework/DB/src/main/java/db/buffers/LocalBufferFile.java@@ -312,6 +312,14 @@ public class LocalBufferFile implements BufferFile {@Overridepublic void setParameter(String name, int value) {+ try {+ if (name.getBytes(STRING_ENCODING).length > MAX_PARAM_NAME_LENGTH) {+ throw new IllegalArgumentException("Parameter name is too long");+ }+ }+ catch (UnsupportedEncodingException e) {+ throw new IllegalArgumentException("Unsupported parameter name", e);+ }userParms.put(name, value);}