Akheon23 / marketlicensing

Automatically exported from code.google.com/p/marketlicensing
Apache License 2.0
0 stars 0 forks source link

NullPointerException in LicenseValidator #40

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
OVERVIEW
Sometimes when a device is unlicensed, the LicenseValidator throws a 
NullPointerException.

STEPS TO REPRODUCE
1. Set up an Android device without any accounts
2. Run an app that uses LVL

RESULTS
Actual: A NullPointerException is sometimes thrown
Expected: No NPE should be thrown

NOTES
The NPE is thrown by LicenseValidator.java line 101.

The issue is that the signedData variable can be null when the server returns 
NOT_LICENSED.  A fix for this problem is to modify the if statement immediately 
above to not match responseCode == NOT_LICENSED.  The code already contains a 
comment that says "skip signature check for unsuccessful requests" but seems to 
do the exact opposite.

Original issue reported on code.google.com by supp...@twofortyfouram.com on 15 Dec 2011 at 4:16

GoogleCodeExporter commented 9 years ago
add the following code at try block of "verify" function seems 
to solve the issue 

catch(NullPointerException e)
{
   handleInvalidResponse();
return;
}

Original comment by androxpl...@gmail.com on 30 Jan 2012 at 12:12

GoogleCodeExporter commented 9 years ago
I prefer not to unnecessarily throw exceptions.  This one is easily avoidable.  
I used:

if (responseCode == LICENSED || responseCode == NOT_LICENSED || responseCode == 
LICENSED_OLD_KEY) {
    // Start of new code
    if (signedData == null) {
        handleInvalidResponse();
        return;
    }
    // End of new code

Original comment by skenned...@gmail.com on 13 Jun 2012 at 9:00

GoogleCodeExporter commented 9 years ago
what the heck is google thinking still not fixing this bug?

Original comment by tomi.ura...@gmail.com on 23 Oct 2012 at 7:24