diff options
| author | Jakob Unterwurzacher | 2025-04-05 11:31:14 +0200 | 
|---|---|---|
| committer | Jakob Unterwurzacher | 2025-04-05 11:46:07 +0200 | 
| commit | c8055829c311ecaf532fd171f3a5d104f873272d (patch) | |
| tree | ac3509886a7264d303add398276980e840e3a9e0 /tests/fsck/fsck_test.go | |
| parent | 810f074e75b4251b1520843b42c204e5a6e376d8 (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
Diffstat (limited to 'tests/fsck/fsck_test.go')
| -rw-r--r-- | tests/fsck/fsck_test.go | 11 | 
1 files changed, 11 insertions, 0 deletions
| 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) | 
