Skip to content

Commit 53002ca

Browse files
committed
Check that writing to a read only file returns an error
Fixes pkg#28
1 parent d06f456 commit 53002ca

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

client_integration_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,23 @@ func TestServerRoughDisconnect(t *testing.T) {
12331233
sftp.Close()
12341234
}
12351235

1236+
// sftp/issue/26 writing to a read only file caused client to loop.
1237+
func TestClientWriteToROFile(t *testing.T) {
1238+
sftp, cmd := testClient(t, READWRITE, NO_DELAY)
1239+
defer cmd.Wait()
1240+
defer sftp.Close()
1241+
1242+
f, err := sftp.Open("/dev/zero")
1243+
if err != nil {
1244+
t.Fatal(err)
1245+
}
1246+
defer f.Close()
1247+
_, err = f.Write([]byte("hello"))
1248+
if err == nil {
1249+
t.Fatal("expected error, got", err)
1250+
}
1251+
}
1252+
12361253
func benchmarkRead(b *testing.B, bufsize int, delay time.Duration) {
12371254
size := 10*1024*1024 + 123 // ~10MiB
12381255

0 commit comments

Comments
 (0)