deptofdefense / AndroidTacticalAssaultKit-CIV

Other
32 stars 14 forks source link

BUG: legacyFindMountRootDirs process.waitFor results in startup deadlock/hang #316

Open rockaport opened 10 months ago

rockaport commented 10 months ago

With Android using more and more APEX files the mount command can return more data than the default read buffer can handle. Calling process.waitFor without reading the buffer first will result in waitFor waiting indefinitely.

Here's an SO post that describes the issue in more detail. I'm open to submitting a pull request, but it might be best to look through the source and find/fix any other instances of this just to be safe.

https://github.com/deptofdefense/AndroidTacticalAssaultKit-CIV/blob/22d11cba15dd5cfe385c0d0790670bc7e9ab7df4/takkernel/engine/src/main/java/com/atakmap/coremap/filesystem/FileSystemUtils.java#L271

            Process proc = new ProcessBuilder().command("mount")
                    .redirectErrorStream(true).start();
            proc.waitFor(); // this needs to be moved to the end
            InputStream is = proc.getInputStream();

            BufferedReader r = new BufferedReader(
                    new InputStreamReader(is, UTF8_CHARSET));
lysek commented 5 months ago

This is also an issue when using ATAK on a rooted phone, where mount command returns much more items than on a non-rooted phone.

bisgroves commented 4 months ago

Do you have a pull request ready to submit?