fixed a number of potential integer overflow issues in the APDU parser