[
https://issues.apache.org/jira/browse/COMPRESS-21?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Stefan Bodewig updated COMPRESS-21:
-----------------------------------
Fix Version/s: 1.0
> CompressUtils#compareByteArrays() looks wrong
> ---------------------------------------------
>
> Key: COMPRESS-21
> URL: https://issues.apache.org/jira/browse/COMPRESS-21
> Project: Commons Compress
> Issue Type: Bug
> Reporter: Sebb
> Fix For: 1.0
>
>
> CompressUtils#compareByteArrays() looks wrong.
> The Javadoc says that it compares two byte arrays, however the arrays are
> treated differently:
> {code}
> public static boolean compareByteArrays(byte[] source, byte[] match) {
> int i = 0;
> while(source.length < i || i < match.length ) {
> if(source[i] != match[i]) {
> return false;
> }
> i++;
> }
> return true;
> }
> {code}
> The code will keep checking bytes from match[] until there is a mismatch with
> source[].
> If source[] is shorther than match[] then ArrayOutOfBoundsException will be
> generated.
> If source[] is longer than match[], then trailing bytes in source[] will be
> ignored.
> Neither behaviour seems particularly useful...
> The method does not appear to be used, so perhaps it should just be deleted?
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.