aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2025-04-05 11:31:14 +0200
committerJakob Unterwurzacher2025-04-05 11:46:07 +0200
commitc8055829c311ecaf532fd171f3a5d104f873272d (patch)
treeac3509886a7264d303add398276980e840e3a9e0
parent810f074e75b4251b1520843b42c204e5a6e376d8 (diff)
tests: fsck: generate evil files with "\r" and "\n" on the fly
Because if we have them in git, we get this: $ go install github.com/rfjakob/gocryptfs/v2@latest go: downloading github.com/rfjakob/gocryptfs/v2 v2.5.2 go: github.com/rfjakob/gocryptfs/v2@latest: create zip: tests/fsck/malleable_base64/27AG8t-XZH7G9ou2OSD_z g: malformed file path "tests/fsck/malleable_base64/27AG8t-XZH7G9ou2OSD_z\ng": invalid char '\n' g: malformed file path "tests/fsck/malleable_base64/27AG8t-XZH7G9ou2OSD_z\rg": invalid char '\r' Fixes: https://github.com/rfjakob/gocryptfs/issues/904 Relates-to: https://github.com/golang/go/issues/28001
-rw-r--r--tests/fsck/.gitignore7
-rw-r--r--tests/fsck/fsck_test.go11
-rw-r--r--tests/fsck/malleable_base64/27AG8t-XZH7G9ou2OSD_z g0
-rw-r--r--tests/fsck/malleable_base64/27AG8t-XZH7G9ou2OSD_z g0
4 files changed, 18 insertions, 0 deletions
diff --git a/tests/fsck/.gitignore b/tests/fsck/.gitignore
new file mode 100644
index 0000000..9c9febc
--- /dev/null
+++ b/tests/fsck/.gitignore
@@ -0,0 +1,7 @@
+# Cannot have these "evil" files in git because they break "go install"
+# https://github.com/golang/go/issues/28001
+#
+# "malleable_base64/27AG8t-XZH7G9ou2OSD_z\ng"
+# "malleable_base64/27AG8t-XZH7G9ou2OSD_z\rg"
+#
+malleable_base64/27AG8t-XZH7G9ou2OSD_z?g
diff --git a/tests/fsck/fsck_test.go b/tests/fsck/fsck_test.go
index b70fd49..de49819 100644
--- a/tests/fsck/fsck_test.go
+++ b/tests/fsck/fsck_test.go
@@ -50,6 +50,17 @@ func TestBrokenFsV14(t *testing.T) {
}
func TestMalleableBase64(t *testing.T) {
+ // Evil filenames. Cannot have them in git, because if we do,
+ // go install github.com/rfjakob/gocryptfs/v2@latest
+ // fails with
+ // g: malformed file path "tests/fsck/malleable_base64/27AG8t-XZH7G9ou2OSD_z\rg": invalid char '\r'
+ // g: malformed file path "tests/fsck/malleable_base64/27AG8t-XZH7G9ou2OSD_z\rg": invalid char '\r'
+ if err := os.WriteFile("malleable_base64/27AG8t-XZH7G9ou2OSD_z\ng", nil, 0644); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.WriteFile("malleable_base64/27AG8t-XZH7G9ou2OSD_z\rg", nil, 0644); err != nil {
+ t.Fatal(err)
+ }
cmd := exec.Command(test_helpers.GocryptfsBinary, "-fsck", "-extpass", "echo test", "malleable_base64")
outBin, err := cmd.CombinedOutput()
out := string(outBin)
diff --git a/tests/fsck/malleable_base64/27AG8t-XZH7G9ou2OSD_z g b/tests/fsck/malleable_base64/27AG8t-XZH7G9ou2OSD_z g
deleted file mode 100644
index e69de29..0000000
--- a/tests/fsck/malleable_base64/27AG8t-XZH7G9ou2OSD_z g
+++ /dev/null
diff --git a/tests/fsck/malleable_base64/27AG8t-XZH7G9ou2OSD_z g b/tests/fsck/malleable_base64/27AG8t-XZH7G9ou2OSD_z g
deleted file mode 100644
index e69de29..0000000
--- a/tests/fsck/malleable_base64/27AG8t-XZH7G9ou2OSD_z g
+++ /dev/null