public final void checkServerTrusted(X509Certificate[]
paramArrayOfX509Certificate, String paramString)
{
if ((paramArrayOfX509Certificate != null) && (
paramArrayOfX509Certificate.length == 1))
paramArrayOfX509Certificate[0].checkValidity();
while (true)
{
return;
this.a.checkServerTrusted(
paramArrayOfX509Certificate, paramString);
}
}
Good to know this isn't used for anything critical, just for, um, mobile banking. void foo(X509Certificate[] a, String unused) {
if( a != null && a.length == 1) a[0].checkValidity();
while(true){
return;
/* never executed stuff */
foo(a, unused);
}
}
X509Certificate.checkValidity()'s javadoc:
http://docs.oracle.com/javase/1.5.0/docs/api/javax/security/...Selections from above link:
Checks that the certificate is currently valid. It is if the current date and time are within the validity period given in the certificate.
Throws:
CertificateExpiredException - if the certificate has expired.
CertificateNotYetValidException - if the certificate is not yet valid.
There has got to be more to their code than this. It does nothing useful except make sure a random certificate is not expired. If there is no certificate, it doesn't fail or return false or anything. What is this!?Could this be a profiler-optimized set of code that really had a LOT more code to it? But then why would the bit of random junk after the return statement exist? Did no one do a proper code-review of this???
[edit: I used JavaSE 1.5 above; but I just checked Android's version and it looks to be the same, just less verbage in the docs.]
I'm not saying that the conclusion of the article is wrong, I'm merely trying to explain why the code blob above looks so weird.
In either case, we have the bytecode; and shouldn't what is written above compile to the same bytecode?
public class C { public int foo() { return 1; int b = 1 + 2; } }
Then compile it (javac C.java). You will get the following:
C.java:4: unreachable statement int b = 1 + 2; ^ C.java:5: missing return statement } ^ 2 errors
Therefore this code is not compileable, thus telling us that the initial code blob could never have run in the first place.
I'm not sure why the decompiler returns non-compiling java code, I just know it does.
I can imagine some poor developer, unable to figure out why it seems to always throw a StackOverflowException, putting that return statement in in frustration, and forgetting about it.
"Not the most interesting technically, but perhaps the most devastating (because of the ease of exploitation) bug is the broken certificate validation in the Chase mobile banking app on Android. Even a primitive network attacker—for example, someone in control of a malicious Wi-Fi access point—can exploit this vulnerability to harvest the login credentials of Chase mobile banking customers."