mirror of
https://github.com/drakkan/sftpgo.git
synced 2024-11-22 07:30:25 +00:00
sftpd: fix the max upload file size check for overwrites
improved test case too
This commit is contained in:
parent
5ff8f75917
commit
975a2f3632
4 changed files with 15 additions and 3 deletions
|
@ -824,6 +824,11 @@ func TestUploadMaxSize(t *testing.T) {
|
|||
assert.Error(t, err)
|
||||
err = ftpUploadFile(testFilePath, testFileName, testFileSize, client, 0)
|
||||
assert.NoError(t, err)
|
||||
// now test overwrite an existing file with a size bigger than the allowed one
|
||||
err = createTestFile(filepath.Join(user.GetHomeDir(), testFileName1), testFileSize1)
|
||||
assert.NoError(t, err)
|
||||
err = ftpUploadFile(testFilePath1, testFileName1, testFileSize1, client, 0)
|
||||
assert.Error(t, err)
|
||||
err = client.Quit()
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
|
|
@ -391,9 +391,6 @@ func (c *Connection) handleSFTPUploadToExistingFile(pflags sftp.FileOpenFlags, r
|
|||
} else {
|
||||
initialSize = fileSize
|
||||
}
|
||||
if maxWriteSize > 0 && isTruncate {
|
||||
maxWriteSize += fileSize
|
||||
}
|
||||
}
|
||||
|
||||
vfs.SetPathPermissions(c.Fs, filePath, c.User.GetUID(), c.User.GetGID())
|
||||
|
|
|
@ -2482,6 +2482,11 @@ func TestUploadMaxSize(t *testing.T) {
|
|||
assert.Error(t, err)
|
||||
err = sftpUploadFile(testFilePath, testFileName, testFileSize, client)
|
||||
assert.NoError(t, err)
|
||||
// now test overwrite an existing file with a size bigger than the allowed one
|
||||
err = createTestFile(filepath.Join(user.GetHomeDir(), testFileName1), testFileSize1)
|
||||
assert.NoError(t, err)
|
||||
err = sftpUploadFile(testFilePath1, testFileName1, testFileSize1, client)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
err = os.Remove(testFilePath)
|
||||
assert.NoError(t, err)
|
||||
|
|
|
@ -701,6 +701,11 @@ func TestUploadMaxSize(t *testing.T) {
|
|||
assert.Error(t, err)
|
||||
err = uploadFile(testFilePath, testFileName, testFileSize, client)
|
||||
assert.NoError(t, err)
|
||||
// now test overwrite an existing file with a size bigger than the allowed one
|
||||
err = createTestFile(filepath.Join(user.GetHomeDir(), testFileName1), testFileSize1)
|
||||
assert.NoError(t, err)
|
||||
err = uploadFile(testFilePath1, testFileName1, testFileSize1, client)
|
||||
assert.Error(t, err)
|
||||
|
||||
err = os.Remove(testFilePath)
|
||||
assert.NoError(t, err)
|
||||
|
|
Loading…
Reference in a new issue