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

Commit bf0c614d authored by Narayan Kamath's avatar Narayan Kamath Committed by Android Git Automerger
Browse files

am c97d1fbb: am 5106dd44: Merge "Throw IllegalArgumentException on invalid hex-strings."

* commit 'c97d1fbb':
  Throw IllegalArgumentException on invalid hex-strings.
parents 1539c267 c97d1fbb
Loading
Loading
Loading
Loading
+3 −9
Original line number Diff line number Diff line
@@ -2203,7 +2203,7 @@ class MountService extends IMountService.Stub
        }
    }

    private String toHex(String password) {
    private static String toHex(String password) {
        if (password == null) {
            return "";
        }
@@ -2211,18 +2211,12 @@ class MountService extends IMountService.Stub
        return new String(HexEncoding.encode(bytes));
    }

    private String fromHex(String hexPassword) {
    private static String fromHex(String hexPassword) throws IllegalArgumentException {
        if (hexPassword == null) {
            return null;
        }

        final byte[] bytes;
        try {
            bytes = HexEncoding.decode(hexPassword.toCharArray(), false);
        } catch (IllegalArgumentException e) {
            return null;
        }

        final byte[] bytes = HexEncoding.decode(hexPassword.toCharArray(), false);
        return new String(bytes, StandardCharsets.UTF_8);
    }