Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5e646320 authored by Michael W's avatar Michael W Committed by Clark Scheff
Browse files

Core: Fix OOB

getExternal___Dir() relies on getExternal___Dirs to return an array
of at least 1 element.
Make sure there is at least one element returned.

(Reference:
BugDump 13-20160513-19 l#45 (FileManager) and L#104 (Gallery)
BugDump 13-20160520-26 L#18 and more (26), just search for
"getExternal" to find all cases of that OOB (>>100 users))

TICKET: RM-232
Change-Id: I56394db135c4c53c972e3bcc8f1df4ea1d4d39e7
(cherry picked from commit aa238e9f)
parent c060ba48
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -2018,6 +2018,11 @@ class ContextImpl extends Context {
            }
            result.add(dir);
        }

        // Make sure there is at least one element, let the callers handle that
        if (result.size() == 0) {
            result.add(null);
        }
        return result.toArray(new File[result.size()]);
    }