Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-0: Review fixes

Ryan Kurtz733e0650c1e1
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/omf/OmfRecord.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/omf/OmfRecord.java
index b580e291ce..5a3c54031b 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/omf/OmfRecord.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/omf/OmfRecord.java
@@ -90,10 +90,16 @@ public abstract class OmfRecord implements StructConverter {
return recordOffset;
}
+ /**
+ * {@return the record checksum}
+ */
public byte getRecordChecksum() {
return checkSum;
}
+ /**
+ * {@return the record data}
+ */
public byte[] getData() {
return data;
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/omf/omf51/Omf51Content.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/omf/omf51/Omf51Content.java
index d74b0e6d40..78fe1434e1 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/omf/omf51/Omf51Content.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/omf/omf51/Omf51Content.java
@@ -25,8 +25,8 @@ import ghidra.util.exception.DuplicateNameException;
public class Omf51Content extends OmfRecord {
private byte segId;
- private short offset;
- private byte[] contentBytes;
+ private int offset;
+ private byte[] dataBytes;
/**
* Creates a new {@link Omf51Content} record
@@ -41,15 +41,8 @@ public class Omf51Content extends OmfRecord {
@Override
public void parseData() throws IOException, OmfException {
segId = dataReader.readNextByte();
- offset = dataReader.readNextShort();
- // Record length includes type byte, length bytes, content, and checksum
- // We need to subtract: type(1) + length(2) + seg_id(1) + offset(2) + checksum(1)
- int remainingBytes = getRecordLength() - 4;
- if (remainingBytes > 0) {
- contentBytes = dataReader.readNextByteArray(remainingBytes);
- } else {
- contentBytes = new byte[0]; // Empty array if no content
- }
+ offset = dataReader.readNextUnsignedShort();
+ dataBytes = dataReader.readNextByteArray((int) (dataEnd - dataReader.getPointerIndex()));
}
/**
@@ -59,6 +52,20 @@ public class Omf51Content extends OmfRecord {
return segId;
}
+ /**
+ * {@return the offset}
+ */
+ public int getOffset() {
+ return offset;
+ }
+
+ /**
+ * {@return the data}
+ */
+ public byte[] getDataBytes() {
+ return dataBytes;
+ }
+
@Override
public DataType toDataType() throws DuplicateNameException, IOException {
StructureDataType struct = new StructureDataType(Omf51RecordTypes.getName(recordType), 0);
@@ -66,7 +73,9 @@ public class Omf51Content extends OmfRecord {
struct.add(WORD, "length", null);
struct.add(BYTE, "SEG ID", null);
struct.add(WORD, "offset", null);
- struct.add(new ArrayDataType(BYTE, contentBytes.length, 1), "content", null);
+ if (dataBytes.length > 0) {
+ struct.add(new ArrayDataType(BYTE, dataBytes.length, 1), "data", null);
+ }
struct.add(BYTE, "checksum", null);
struct.setCategoryPath(new CategoryPath(OmfUtils.CATEGORY_PATH));