aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org
diff options
context:
space:
mode:
authorMichael Dardis <git@md-5.net>2020-03-04 15:25:09 +1100
committerMatthias Sohn <matthias.sohn@sap.com>2020-03-04 16:34:01 +0100
commitd7f304045af2f602c5b0c1a26d2c7f643753cf8f (patch)
tree1d16efc26e1fa0ae8f0587647557cb0b2ff20cee /org.eclipse.jgit.test/tst/org
parent95fd662dd3f5a0808cacc8066a0f43f15684301d (diff)
downloadjgit-d7f304045af2f602c5b0c1a26d2c7f643753cf8f.tar.gz
jgit-d7f304045af2f602c5b0c1a26d2c7f643753cf8f.zip
Add validation to hex decoder
Does not fix any issue but prevents user from shooting themselves in the foot with improper configuration. Suggested by Demetr Starshov at https://git.eclipse.org/r/#/c/157681/ Change-Id: I006d65022f0a7d4066970825d00080c59404fdc3 Signed-off-by: Michael Dardis <git@md-5.net> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HexTest.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HexTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HexTest.java
index 32af07f259..5f3ab0b775 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HexTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HexTest.java
@@ -42,6 +42,31 @@ public class HexTest {
}
}
+ @Test(expected = IllegalArgumentException.class)
+ public void testIllegal() {
+ decode("0011test00");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testIllegal2() {
+ decode("0123456789abcdefgh");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testIllegal3() {
+ decode("0123456789abcdef-_+*");
+ }
+
+ @Test
+ public void testLegal() {
+ decode("0123456789abcdef");
+ }
+
+ @Test
+ public void testLegal2() {
+ decode("deadbeef");
+ }
+
private static byte[] b(String str) {
return Constants.encode(str);
}