Skip to content

NPE when loading profiles, fails when sorting by version name #33

@eighthave

Description

@eighthave

I get this NPE when working with profiles I generated myself from the attached file.

$ libscout --opmode match --android-sdk /home/fdroid/android-sdk/platforms/android-29/android.jar --libscout-conf /home/fdroid/code/reddr/LibScout/config/LibScout.toml --log-dir /data/ttt-apks/libraries/run-match.sh-1598623728-logs --profiles-dir ./profiles --json-dir /data/ttt-apks/random-google-play//json /data/ttt-apks/random-google-play/
Exception in thread "main" java.lang.NullPointerException
        at de.infsec.tpl.profile.LibProfile$LibProfileComparator.compare(LibProfile.java:68)
        at de.infsec.tpl.profile.LibProfile$LibProfileComparator.compare(LibProfile.java:65)
        at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
        at java.base/java.util.TimSort.sort(TimSort.java:234)
        at java.base/java.util.Arrays.sort(Arrays.java:1515)
        at java.base/java.util.ArrayList.sort(ArrayList.java:1750)
        at de.infsec.tpl.profile.Profile.loadLibraryProfiles(Profile.java:87)
        at de.infsec.tpl.TplCLI.main(TplCLI.java:122)

Here is my proposed fix for --opmode match:

--- a/src/de/infsec/tpl/profile/Profile.java
+++ b/src/de/infsec/tpl/profile/Profile.java
@@ -81,6 +81,10 @@ public abstract class Profile implements Serializable {
                        // de-serialize library profiles
                        for (File f : Utils.collectFiles(profilesDir, new String[]{LibraryProfiler.FILE_EXT_LIB_PROFILE})) {
                                LibProfile lp = (LibProfile) Utils.disk2Object(f);
+                               if (lp == null || lp.description == null) {
+                                   System.err.println("ERROR: " + f + " produces a null profile!");
+                                   continue;
+                               }
                                profiles.add(lp);
                        }
 

PyzeLibrary_2.5.0.libv.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions