summaryrefslogtreecommitdiff
path: root/internal/nametransform/names_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/nametransform/names_test.go')
-rw-r--r--internal/nametransform/names_test.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/internal/nametransform/names_test.go b/internal/nametransform/names_test.go
index d772af2..0254777 100644
--- a/internal/nametransform/names_test.go
+++ b/internal/nametransform/names_test.go
@@ -32,3 +32,20 @@ func TestPad16(t *testing.T) {
}
}
}
+
+// TestUnpad16Garbage - unPad16 should never crash on corrupt or malicious inputs
+func TestUnpad16Garbage(t *testing.T) {
+ var testCases [][]byte
+ testCases = append(testCases, make([]byte, 0))
+ testCases = append(testCases, make([]byte, 16))
+ testCases = append(testCases, make([]byte, 1))
+ testCases = append(testCases, make([]byte, 17))
+ testCases = append(testCases, bytes.Repeat([]byte{16}, 16))
+ testCases = append(testCases, bytes.Repeat([]byte{17}, 16))
+ for _, v := range testCases {
+ _, err := unPad16([]byte(v))
+ if err == nil {
+ t.Fail()
+ }
+ }
+}