Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions core/src/main/java/org/bouncycastle/util/Arrays.java
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,11 @@ public static BigInteger[] copyOf(BigInteger[] data, int newLength)
public static byte[] copyOfRange(byte[] data, int from, int to)
{
int newLength = getLength(from, to);
if(newLength < 0) {
StringBuffer sb = new StringBuffer();
sb.append(from).append(" > ").append(to);
throw new IllegalArgumentException(sb.toString());
}

byte[] tmp = new byte[newLength];

Expand Down Expand Up @@ -895,8 +900,8 @@ private static int getLength(int from, int to)
int newLength = to - from;
if (newLength < 0)
{
StringBuffer sb = new StringBuffer(from);
sb.append(" > ").append(to);
StringBuffer sb = new StringBuffer();
sb.append(from).append(" > ").append(to);
throw new IllegalArgumentException(sb.toString());
}
return newLength;
Expand Down