summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
eee9f61)
We want to get enough information about the target device to verify
that the new firmware matches, so fetch 512 bytes instead of just
barely enough to cover the romconfig data.
Also catch out-of-bounds accesses and handle them, in case even this
large array isn't enough.
Signed-off-by: Keith Packard <keithp@keithp.com>
public AltosRomconfig romconfig() throws InterruptedException {
try {
public AltosRomconfig romconfig() throws InterruptedException {
try {
- byte[] bytes = read_memory(0xa0, 10);
- AltosHexfile hexfile = new AltosHexfile (bytes, 0xa0);
+ byte[] bytes = read_memory(0x00, 0x200);
+ AltosHexfile hexfile = new AltosHexfile (bytes, 0x00);
return new AltosRomconfig(hexfile);
} catch (IOException ie) {
}
return new AltosRomconfig(hexfile);
} catch (IOException ie) {
}
if (usb_descriptors == null)
return -1;
if (usb_descriptors == null)
return -1;
- /* Walk the descriptors looking for the device */
- a = usb_descriptors.address;
- while (get_u8(a+1) != AO_USB_DESC_DEVICE) {
- int delta = get_u8(a);
- a += delta;
- if (delta == 0 || a >= max_address)
- return -1;
+ try {
+ /* Walk the descriptors looking for the device */
+ a = usb_descriptors.address;
+ while (get_u8(a+1) != AO_USB_DESC_DEVICE) {
+ int delta = get_u8(a);
+ a += delta;
+ if (delta == 0 || a >= max_address)
+ return -1;
+ }
+ return a;
+ } catch (ArrayIndexOutOfBoundsException ae) {
+ return -1;
}
public AltosUsbId find_usb_id() {
}
public AltosUsbId find_usb_id() {
System.out.printf("no symbol %s\n", name);
throw new AltosNoSymbol(name);
}
System.out.printf("no symbol %s\n", name);
throw new AltosNoSymbol(name);
}
- if (hexfile.address <= symbol.address && symbol.address + len < hexfile.max_address) {
+ if (hexfile.address <= symbol.address && symbol.address + len <= hexfile.max_address) {
System.out.printf("%s: %x\n", name, symbol.address);
return symbol.address;
}
System.out.printf("%s: %x\n", name, symbol.address);
return symbol.address;
}
- System.out.printf("invalid symbol addr %x range is %x - %x\n",
- symbol.address, hexfile.address, hexfile.max_address);
+ System.out.printf("invalid symbol addr %x len %d range is %x - %x\n",
+ symbol.address, len, hexfile.address, hexfile.max_address);
throw new AltosNoSymbol(name);
}
throw new AltosNoSymbol(name);
}