mirror of
https://github.com/AppleCommander/AppleCommander.git
synced 2024-12-21 17:29:55 +00:00
Added a little bit of range checking.
This commit is contained in:
parent
44bb363c06
commit
2ae3f2118c
@ -39,6 +39,9 @@ public class AppleUtil {
|
||||
* A word is two bytes, in standard Apple LO/HI format.
|
||||
*/
|
||||
public static int getWordValue(byte[] buffer, int offset) {
|
||||
if (offset+1 > buffer.length) {
|
||||
return 0;
|
||||
}
|
||||
return getWordValue(buffer[offset], buffer[offset+1]);
|
||||
}
|
||||
/**
|
||||
@ -62,6 +65,9 @@ public class AppleUtil {
|
||||
* Stored in standard Apple LO/HI format.
|
||||
*/
|
||||
public static int get3ByteValue(byte[] buffer, int offset) {
|
||||
if (offset+2 > buffer.length) {
|
||||
return 0;
|
||||
}
|
||||
return getUnsignedByte(buffer[offset])
|
||||
+ getUnsignedByte(buffer[offset+1])*256
|
||||
+ getUnsignedByte(buffer[offset+2])*65536;
|
||||
|
Loading…
Reference in New Issue
Block a user