Make sure in-place AES respects reader index

This commit is contained in:
Andrew Steinborn
2019-11-09 21:30:46 -05:00
parent d73496e8df
commit af0903050d

View File

@@ -40,10 +40,10 @@ public class JavaVelocityCipher implements VelocityCipher {
Preconditions.checkArgument(source.hasArray(), "No source array"); Preconditions.checkArgument(source.hasArray(), "No source array");
int inBytes = source.readableBytes(); int inBytes = source.readableBytes();
int baseOffset = source.arrayOffset() + source.readerIndex();
try { try {
cipher.update(source.array(), source.arrayOffset(), inBytes, source.array(), cipher.update(source.array(), baseOffset, inBytes, source.array(), baseOffset);
source.arrayOffset());
} catch (ShortBufferException ex) { } catch (ShortBufferException ex) {
/* This _really_ shouldn't happen - AES CFB8 will work in place. /* This _really_ shouldn't happen - AES CFB8 will work in place.
If you run into this, that means that for whatever reason the Java Runtime has determined If you run into this, that means that for whatever reason the Java Runtime has determined