Fixed issue with RMI registration validation fragmentation count

This commit is contained in:
nathan 2020-05-07 14:51:31 +02:00
parent 9d9082903a
commit 450f1aa5fb

View File

@ -146,7 +146,7 @@ class RegistrationWrapperClient extends RegistrationWrapper {
private static private static
byte[][] divideArray(byte[] source, int chunksize) { byte[][] divideArray(byte[] source, int chunksize) {
int fragments = (int) Math.ceil(source.length / ((double) chunksize + 2)); int fragments = (int) Math.ceil(source.length / ((double) chunksize));
if (fragments > 127) { if (fragments > 127) {
// cannot allow more than 127 // cannot allow more than 127
return null; return null;
@ -165,9 +165,9 @@ class RegistrationWrapperClient extends RegistrationWrapper {
else { else {
length = chunksize; length = chunksize;
} }
splitArray[i] = new byte[length+2]; splitArray[i] = new byte[length + 2];
splitArray[i][0] = (byte) i; splitArray[i][0] = (byte) i; // index
splitArray[i][1] = (byte) fragments; splitArray[i][1] = (byte) fragments; // total number of fragments
System.arraycopy(source, start, splitArray[i], 2, length); System.arraycopy(source, start, splitArray[i], 2, length);
start += chunksize; start += chunksize;