Ghidra is a software reverse engineering (SRE) framework
GP-5199: per review GP-5199: forgot a bit GP-5199: fix for 0 length
d-millarc2224aa53853
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/debug/DebugMisc.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/debug/DebugMisc.javaindex a1453f1972..46d608bbe4 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/debug/DebugMisc.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/debug/DebugMisc.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.@@ -83,8 +83,18 @@ public class DebugMisc implements StructConverter {actualData =(unicode ? reader.readNextUnicodeString(length) : reader.readNextAsciiString());}+ else if (length == 0 && !unicode) {+ actualData = reader.readNextAsciiString();+ // NB: should be a multiple of 4 per winnt.h+ // 13 = len(start of struct) + null+ length = (int) Math.ceil((actualData.length() + 13)/4.0)*4;+ if (length > DebugDirectory.IMAGE_SIZEOF_DEBUG_DIRECTORY) {+ length = DebugDirectory.IMAGE_SIZEOF_DEBUG_DIRECTORY;+ }+ Msg.warn(this, "Zero length structure - defaulting to " + Integer.toHexString(length));+ }else {- Msg.error(this, "Bad string length " + Integer.toHexString(length));+ Msg.error(this, "Bad structure length " + Integer.toHexString(length));}reader.setPointerIndex(oldIndex);