-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #379 from Sarenor/implement-input-stream-validation
Implement input stream validation
- Loading branch information
Showing
5 changed files
with
344 additions
and
173 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
validator/src/main/java/org/mustangproject/validator/ByteArraySearcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.mustangproject.validator; | ||
|
||
public final class ByteArraySearcher { | ||
|
||
private ByteArraySearcher() { | ||
} | ||
|
||
public static boolean contains(byte[] haystack, byte[] needle) { | ||
if (needle.length > haystack.length) { | ||
return false; | ||
} | ||
|
||
for (int i = 0; i <= haystack.length - needle.length; i++) { | ||
boolean found = true; | ||
for (int j = 0; j < needle.length; j++) { | ||
if (haystack[i + j] != needle[j]) { | ||
found = false; | ||
break; | ||
} | ||
} | ||
if (found) { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.