Fix possible null dereference
This commit is contained in:
parent
fa15c73220
commit
796bef9ad2
@ -433,6 +433,12 @@ public final class SmartPGPApplet extends Applet {
|
|||||||
|
|
||||||
case Constants.TAG_CARDHOLDER_CERTIFICATE:
|
case Constants.TAG_CARDHOLDER_CERTIFICATE:
|
||||||
k = currentTagOccurenceToKey();
|
k = currentTagOccurenceToKey();
|
||||||
|
|
||||||
|
if(k == null) {
|
||||||
|
ISOException.throwIt(Constants.SW_REFERENCE_DATA_NOT_FOUND);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
off = Util.arrayCopyNonAtomic(k.certificate, (short)0,
|
off = Util.arrayCopyNonAtomic(k.certificate, (short)0,
|
||||||
buf, off,
|
buf, off,
|
||||||
k.certificate_length);
|
k.certificate_length);
|
||||||
@ -461,6 +467,11 @@ public final class SmartPGPApplet extends Applet {
|
|||||||
|
|
||||||
final PGPKey k = currentTagOccurenceToKey();
|
final PGPKey k = currentTagOccurenceToKey();
|
||||||
|
|
||||||
|
if(k == null) {
|
||||||
|
ISOException.throwIt(Constants.SW_REFERENCE_DATA_NOT_FOUND);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
transients.setCurrentTagOccurrence((byte)(transients.currentTagOccurrence() + 1));
|
transients.setCurrentTagOccurrence((byte)(transients.currentTagOccurrence() + 1));
|
||||||
|
|
||||||
return Util.arrayCopyNonAtomic(k.certificate, (short)0,
|
return Util.arrayCopyNonAtomic(k.certificate, (short)0,
|
||||||
@ -774,6 +785,8 @@ public final class SmartPGPApplet extends Applet {
|
|||||||
|
|
||||||
final byte[] buf = transients.buffer;
|
final byte[] buf = transients.buffer;
|
||||||
|
|
||||||
|
PGPKey k = null;
|
||||||
|
|
||||||
if(isOdd) {
|
if(isOdd) {
|
||||||
|
|
||||||
assertAdmin();
|
assertAdmin();
|
||||||
@ -800,8 +813,6 @@ public final class SmartPGPApplet extends Applet {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PGPKey k = null;
|
|
||||||
|
|
||||||
switch(Util.getShort(buf, off)) {
|
switch(Util.getShort(buf, off)) {
|
||||||
case Constants.CRT_SIGNATURE_KEY:
|
case Constants.CRT_SIGNATURE_KEY:
|
||||||
k = data.pgp_keys[Persistent.PGP_KEYS_OFFSET_SIG];
|
k = data.pgp_keys[Persistent.PGP_KEYS_OFFSET_SIG];
|
||||||
@ -1005,7 +1016,12 @@ public final class SmartPGPApplet extends Applet {
|
|||||||
|
|
||||||
case Constants.TAG_CARDHOLDER_CERTIFICATE:
|
case Constants.TAG_CARDHOLDER_CERTIFICATE:
|
||||||
assertAdmin();
|
assertAdmin();
|
||||||
currentTagOccurenceToKey().setCertificate(buf, (short)0, lc);
|
k = currentTagOccurenceToKey();
|
||||||
|
if(k == null) {
|
||||||
|
ISOException.throwIt(Constants.SW_REFERENCE_DATA_NOT_FOUND);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
k.setCertificate(buf, (short)0, lc);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Constants.TAG_ALGORITHM_ATTRIBUTES_SIG:
|
case Constants.TAG_ALGORITHM_ATTRIBUTES_SIG:
|
||||||
|
Loading…
Reference in New Issue
Block a user