Unexpected error during digest computation, Wrong offset or not enough space to store the digest #9
Description
The source code has a copy of org.apache.mina.proxy.utils.MD4.java , but its method
protected int engineDigest(byte[] buf, int offset, int len)
has offset + len > buf.length
instead of offset + len >= buf.length
(that e.g. mina 2.0.4 has).
If the parent project imports a version of mina that has ">=", a sync from an existing file sometimes (probably for very specific file content or size) yield the following Exception:
java.lang.RuntimeException: Unexpected error during digest computation
at com.salesforce.zsync.internal.Checksum.setChecksum(Checksum.java:86)
at com.salesforce.zsync.internal.DoubleBlockMatcher.tryMatchBoth(DoubleBlockMatcher.java:170)
at com.salesforce.zsync.internal.DoubleBlockMatcher.match(DoubleBlockMatcher.java:99)
at com.salesforce.zsync.Zsync.processInputFile(Zsync.java:449)
at com.salesforce.zsync.Zsync.processInputFiles(Zsync.java:430)
at com.salesforce.zsync.Zsync.zsyncInternal(Zsync.java:361)
at com.salesforce.zsync.Zsync.zsync(Zsync.java:314)
...
Suppressed: com.salesforce.zsync.internal.ChecksumValidationIOException
at com.salesforce.zsync.internal.OutputFileWriter.close(OutputFileWriter.java:213)
at com.salesforce.zsync.Zsync.zsyncInternal(Zsync.java:365)
... 12 more
Caused by: java.security.DigestException: Wrong offset or not enough space to store the digest
at org.apache.mina.proxy.utils.MD4.engineDigest(MD4.java:163)
at java.security.MessageDigest$Delegate.engineDigest(MessageDigest.java:593)
at java.security.MessageDigest.digest(MessageDigest.java:392)
at com.salesforce.zsync.internal.Checksum.setChecksum(Checksum.java:84)
... 17 more
That specific exception was for offset
= 0 and len
= 16, and buf.length
= 16 .
It seems to be pretty much the only .java file of the source code that has a package outside com.salesforce.zsync, we may want to change the package to prevent that problem.
My workaround was to remove the other dependency/import that used Mina.