freezer: handle exception in locks file format
Safeguard /proc/locks processing from wrongly formatted /proc/locks
files
Bug: 179171387
Test: could not reproduce the issue, but verified that no crashes
occurred in a prolonged test (4hrs+)
Change-Id: Ia8a12903f2e520e51780c8b05876aa1c9083e92b
(cherry picked from commit fb4f4073f6)
This commit is contained in:
@@ -1406,7 +1406,7 @@ public class Process {
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static boolean hasFileLocks(int pid) throws IOException {
|
||||
public static boolean hasFileLocks(int pid) throws Exception {
|
||||
BufferedReader br = null;
|
||||
|
||||
try {
|
||||
@@ -1418,8 +1418,13 @@ public class Process {
|
||||
|
||||
for (int i = 0; i < 5 && st.hasMoreTokens(); i++) {
|
||||
String str = st.nextToken();
|
||||
if (i == 4 && Integer.parseInt(str) == pid) {
|
||||
return true;
|
||||
try {
|
||||
if (i == 4 && Integer.parseInt(str) == pid) {
|
||||
return true;
|
||||
}
|
||||
} catch (NumberFormatException nfe) {
|
||||
throw new Exception("Exception parsing /proc/locks at \" "
|
||||
+ line + " \", token #" + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1114,7 +1114,7 @@ public final class CachedAppOptimizer {
|
||||
}
|
||||
return;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
Slog.e(TAG_AM, "Not freezing. Unable to check file locks for " + name + "(" + pid
|
||||
+ "): " + e);
|
||||
return;
|
||||
@@ -1192,7 +1192,7 @@ public final class CachedAppOptimizer {
|
||||
unfreezeAppLocked(proc);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
Slog.e(TAG_AM, "Unable to check file locks for " + name + "(" + pid + "): " + e);
|
||||
synchronized (mAm) {
|
||||
unfreezeAppLocked(proc);
|
||||
|
||||
Reference in New Issue
Block a user