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

Commit 92cfb7fc authored by Hall Liu's avatar Hall Liu Committed by Android (Google) Code Review
Browse files

Merge "Prevent multi-threaded access to digest object" into nyc-dev

parents 6fdd3afd 792ad96e
Loading
Loading
Loading
Loading
+13 −8
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ final public class Log {
    public static final boolean ERROR = isLoggable(android.util.Log.ERROR);

    private static MessageDigest sMessageDigest;
    private static final Object sMessageDigestLock = new Object();

    private Log() {}

@@ -57,7 +58,9 @@ final public class Log {
                } catch (NoSuchAlgorithmException e) {
                    md = null;
                }
                synchronized (sMessageDigestLock) {
                    sMessageDigest = md;
                }
                return null;
            }
        }.execute();
@@ -187,6 +190,7 @@ final public class Log {
    }

    private static String secureHash(byte[] input) {
        synchronized (sMessageDigestLock) {
            if (sMessageDigest != null) {
                sMessageDigest.reset();
                sMessageDigest.update(input);
@@ -196,6 +200,7 @@ final public class Log {
                return "Uninitialized SHA1";
            }
        }
    }

    private static String encodeHex(byte[] bytes) {
        StringBuffer hex = new StringBuffer(bytes.length * 2);