Download tasks/codeql_java_benchmark_top30_v2/morefixes-21b89e6983680bd0068c/patch.diff from Benchanything/checkerbench: direct link, hf CLI and curl.
- Browser
- Download file 7.01 kB
-
https://huggingface.co/datasets/Benchanything/checkerbench/resolve/main/tasks/codeql_java_benchmark_top30_v2/morefixes-21b89e6983680bd0068c/patch.diff
- Command line
-
hf download hf://datasets/Benchanything/checkerbench/tasks/codeql_java_benchmark_top30_v2/morefixes-21b89e6983680bd0068c/patch.diff
-
curl -L -o patch.diff https://huggingface.co/datasets/Benchanything/checkerbench/resolve/main/tasks/codeql_java_benchmark_top30_v2/morefixes-21b89e6983680bd0068c/patch.diff
7.01 kB
| diff --git a/src/main/java/com/southernstorm/noise/protocol/AESGCMFallbackCipherState.java b/src/main/java/com/southernstorm/noise/protocol/AESGCMFallbackCipherState.java | |
| index 7cd2b74..f627be3 100644 | |
| --- a/src/main/java/com/southernstorm/noise/protocol/AESGCMFallbackCipherState.java | |
| +++ b/src/main/java/com/southernstorm/noise/protocol/AESGCMFallbackCipherState.java | |
| class AESGCMFallbackCipherState implements CipherState { | |
| byte[] ciphertext, int ciphertextOffset, int length) | |
| throws ShortBufferException { | |
| int space; | |
| - if (ciphertextOffset > ciphertext.length) | |
| - space = 0; | |
| - else | |
| - space = ciphertext.length - ciphertextOffset; | |
| + if (ciphertextOffset < 0 || ciphertextOffset > ciphertext.length) | |
| + throw new IllegalArgumentException(); | |
| + if (length < 0 || plaintextOffset < 0 || plaintextOffset > plaintext.length) | |
| + throw new IllegalArgumentException(); | |
| + space = ciphertext.length - ciphertextOffset; | |
| if (!haskey) { | |
| // The key is not set yet - return the plaintext as-is. | |
| if (length > space) | |
| class AESGCMFallbackCipherState implements CipherState { | |
| int ciphertextOffset, byte[] plaintext, int plaintextOffset, | |
| int length) throws ShortBufferException, BadPaddingException { | |
| int space; | |
| - if (ciphertextOffset > ciphertext.length) | |
| - space = 0; | |
| + if (ciphertextOffset < 0 || ciphertextOffset > ciphertext.length) | |
| + throw new IllegalArgumentException(); | |
| else | |
| space = ciphertext.length - ciphertextOffset; | |
| if (length > space) | |
| throw new ShortBufferException(); | |
| - if (plaintextOffset > plaintext.length) | |
| - space = 0; | |
| - else | |
| - space = plaintext.length - plaintextOffset; | |
| + if (length < 0 || plaintextOffset < 0 || plaintextOffset > plaintext.length) | |
| + throw new IllegalArgumentException(); | |
| + space = plaintext.length - plaintextOffset; | |
| if (!haskey) { | |
| // The key is not set yet - return the ciphertext as-is. | |
| if (length > space) | |
| diff --git a/src/main/java/com/southernstorm/noise/protocol/AESGCMOnCtrCipherState.java b/src/main/java/com/southernstorm/noise/protocol/AESGCMOnCtrCipherState.java | |
| index deada67..df40945 100644 | |
| --- a/src/main/java/com/southernstorm/noise/protocol/AESGCMOnCtrCipherState.java | |
| +++ b/src/main/java/com/southernstorm/noise/protocol/AESGCMOnCtrCipherState.java | |
| class AESGCMOnCtrCipherState implements CipherState { | |
| byte[] ciphertext, int ciphertextOffset, int length) | |
| throws ShortBufferException { | |
| int space; | |
| - if (ciphertextOffset > ciphertext.length) | |
| - space = 0; | |
| - else | |
| - space = ciphertext.length - ciphertextOffset; | |
| + if (ciphertextOffset < 0 || ciphertextOffset > ciphertext.length) | |
| + throw new IllegalArgumentException(); | |
| + if (length < 0 || plaintextOffset < 0 || plaintextOffset > plaintext.length) | |
| + throw new IllegalArgumentException(); | |
| + space = ciphertext.length - ciphertextOffset; | |
| if (keySpec == null) { | |
| // The key is not set yet - return the plaintext as-is. | |
| if (length > space) | |
| class AESGCMOnCtrCipherState implements CipherState { | |
| int ciphertextOffset, byte[] plaintext, int plaintextOffset, | |
| int length) throws ShortBufferException, BadPaddingException { | |
| int space; | |
| - if (ciphertextOffset > ciphertext.length) | |
| - space = 0; | |
| + if (ciphertextOffset < 0 || ciphertextOffset > ciphertext.length) | |
| + throw new IllegalArgumentException(); | |
| else | |
| space = ciphertext.length - ciphertextOffset; | |
| if (length > space) | |
| throw new ShortBufferException(); | |
| - if (plaintextOffset > plaintext.length) | |
| - space = 0; | |
| - else | |
| - space = plaintext.length - plaintextOffset; | |
| + if (length < 0 || plaintextOffset < 0 || plaintextOffset > plaintext.length) | |
| + throw new IllegalArgumentException(); | |
| + space = plaintext.length - plaintextOffset; | |
| if (keySpec == null) { | |
| // The key is not set yet - return the ciphertext as-is. | |
| if (length > space) | |
| diff --git a/src/main/java/com/southernstorm/noise/protocol/ChaChaPolyCipherState.java b/src/main/java/com/southernstorm/noise/protocol/ChaChaPolyCipherState.java | |
| index 25b1a4c..40ce2bc 100644 | |
| --- a/src/main/java/com/southernstorm/noise/protocol/ChaChaPolyCipherState.java | |
| +++ b/src/main/java/com/southernstorm/noise/protocol/ChaChaPolyCipherState.java | |
| class ChaChaPolyCipherState implements CipherState { | |
| public int encryptWithAd(byte[] ad, byte[] plaintext, int plaintextOffset, | |
| byte[] ciphertext, int ciphertextOffset, int length) throws ShortBufferException { | |
| int space; | |
| - if (ciphertextOffset > ciphertext.length) | |
| - space = 0; | |
| - else | |
| - space = ciphertext.length - ciphertextOffset; | |
| + if (ciphertextOffset < 0 || ciphertextOffset > ciphertext.length) | |
| + throw new IllegalArgumentException(); | |
| + if (length < 0 || plaintextOffset < 0 || plaintextOffset > plaintext.length) | |
| + throw new IllegalArgumentException(); | |
| + space = ciphertext.length - ciphertextOffset; | |
| if (!haskey) { | |
| // The key is not set yet - return the plaintext as-is. | |
| if (length > space) | |
| class ChaChaPolyCipherState implements CipherState { | |
| int ciphertextOffset, byte[] plaintext, int plaintextOffset, | |
| int length) throws ShortBufferException, BadPaddingException { | |
| int space; | |
| - if (ciphertextOffset > ciphertext.length) | |
| - space = 0; | |
| + if (ciphertextOffset < 0 || ciphertextOffset > ciphertext.length) | |
| + throw new IllegalArgumentException(); | |
| else | |
| space = ciphertext.length - ciphertextOffset; | |
| if (length > space) | |
| throw new ShortBufferException(); | |
| - if (plaintextOffset > plaintext.length) | |
| - space = 0; | |
| - else | |
| - space = plaintext.length - plaintextOffset; | |
| + if (length < 0 || plaintextOffset < 0 || plaintextOffset > plaintext.length) | |
| + throw new IllegalArgumentException(); | |
| + space = plaintext.length - plaintextOffset; | |
| if (!haskey) { | |
| // The key is not set yet - return the ciphertext as-is. | |
| if (length > space) | |
| diff --git a/src/main/java/com/southernstorm/noise/protocol/CipherState.java b/src/main/java/com/southernstorm/noise/protocol/CipherState.java | |
| index 3168139..74f808b 100644 | |
| --- a/src/main/java/com/southernstorm/noise/protocol/CipherState.java | |
| +++ b/src/main/java/com/southernstorm/noise/protocol/CipherState.java | |
| public interface CipherState extends Destroyable { | |
| * | |
| * @throws IllegalStateException The nonce has wrapped around. | |
| * | |
| + * @throws IllegalArgumentException One of the parameters is out of range. | |
| + * | |
| * The plaintext and ciphertext buffers can be the same for in-place | |
| * encryption. In that case, plaintextOffset must be identical to | |
| * ciphertextOffset. | |
| public interface CipherState extends Destroyable { | |
| * | |
| * @throws IllegalStateException The nonce has wrapped around. | |
| * | |
| + * @throws IllegalArgumentException One of the parameters is out of range. | |
| + * | |
| * The plaintext and ciphertext buffers can be the same for in-place | |
| * decryption. In that case, ciphertextOffset must be identical to | |
| * plaintextOffset. | |