GP-6713 check length calc

This commit is contained in:
dev747368
2026-04-20 17:07:55 +00:00
parent 5a209ba931
commit 0e1484a20c
2 changed files with 14 additions and 8 deletions

View File

@@ -25,7 +25,10 @@ public class BTreeRootNodeDescriptor extends BTreeNodeDescriptor {
nodes.add( this );
int nodeSize = headerRecord.getNodeSize() & 0xffff;
int nodeSize = Short.toUnsignedInt(headerRecord.getNodeSize());
if (nodeSize == 0) {
throw new IOException("Bad nodeSize: " + nodeSize);
}
for ( int i = nodeSize ; i < reader.length() ; i += nodeSize ) {
reader.setPointerIndex( i );

View File

@@ -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.
@@ -15,15 +15,15 @@
*/
package ghidra.file.formats.ios.btree;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.StructConverterUtil;
import ghidra.program.model.data.DataType;
import ghidra.util.exception.DuplicateNameException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class BTreeRootNodeDescriptor extends BTreeNodeDescriptor {
private BTreeHeaderRecord headerRecord;
@@ -40,7 +40,10 @@ public class BTreeRootNodeDescriptor extends BTreeNodeDescriptor {
nodes.add( this );
int nodeSize = headerRecord.getNodeSize() & 0xffff;
int nodeSize = Short.toUnsignedInt(headerRecord.getNodeSize());
if (nodeSize == 0) {
throw new IOException("Bad nodeSize: " + nodeSize);
}
for ( int i = nodeSize ; i < reader.length() ; i += nodeSize ) {
reader.setPointerIndex( i );