Merge "Throw IllegalArgumentException on invalid hex-strings."
This commit is contained in:
@@ -2155,7 +2155,7 @@ class MountService extends IMountService.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String toHex(String password) {
|
private static String toHex(String password) {
|
||||||
if (password == null) {
|
if (password == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -2163,18 +2163,12 @@ class MountService extends IMountService.Stub
|
|||||||
return new String(HexEncoding.encode(bytes));
|
return new String(HexEncoding.encode(bytes));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String fromHex(String hexPassword) {
|
private static String fromHex(String hexPassword) throws IllegalArgumentException {
|
||||||
if (hexPassword == null) {
|
if (hexPassword == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final byte[] bytes;
|
final byte[] bytes = HexEncoding.decode(hexPassword.toCharArray(), false);
|
||||||
try {
|
|
||||||
bytes = HexEncoding.decode(hexPassword.toCharArray(), false);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new String(bytes, StandardCharsets.UTF_8);
|
return new String(bytes, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user