Skip to content

Commit bd5fe46

Browse files
committed
CID 1264632: Rely on a known and widely available encoding UTF8
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> (cherry picked from commit 0763b55) Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 969bbb0 commit bd5fe46

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎utils/src/com/cloud/utils/ConstantTimeComparator.java‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
package com.cloud.utils;
2121

22+
import java.nio.charset.Charset;
23+
2224
public class ConstantTimeComparator {
2325

2426
public static boolean compareBytes(byte[] b1, byte[] b2) {
@@ -34,6 +36,7 @@ public static boolean compareBytes(byte[] b1, byte[] b2) {
3436
}
3537

3638
public static boolean compareStrings(String s1, String s2) {
37-
return compareBytes(s1.getBytes(), s2.getBytes());
39+
final Charset encoding = Charset.forName("UTF-8");
40+
return compareBytes(s1.getBytes(encoding), s2.getBytes(encoding));
3841
}
3942
}

0 commit comments

Comments
 (0)