mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
Check pathlength before reading metadata (#13080)
fixes bug where the server returns 503 instead of 400 if objectName is longer than 255 characters Fixes regression introduced in #12942
This commit is contained in:
parent
c11a2ac396
commit
27f895cf2c
@ -397,6 +397,10 @@ func (s *xlStorage) Healing() *healingTracker {
|
||||
}
|
||||
|
||||
func (s *xlStorage) readMetadata(itemPath string) ([]byte, error) {
|
||||
if err := checkPathLength(itemPath); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
f, err := OpenFile(itemPath, readMode, 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -1818,3 +1818,23 @@ func TestXLStorageVerifyFile(t *testing.T) {
|
||||
t.Fatal("expected to fail bitrot check")
|
||||
}
|
||||
}
|
||||
|
||||
// TestXLStorageReadMetadata tests readMetadata
|
||||
func TestXLStorageReadMetadata(t *testing.T) {
|
||||
volume, object := "test-vol", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
tmpDir, err := ioutil.TempDir("", "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
disk, err := newLocalXLStorage(tmpDir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
disk.MakeVol(context.Background(), volume)
|
||||
if _, err := disk.readMetadata(pathJoin(tmpDir, volume, object)); err != errFileNameTooLong {
|
||||
t.Fatalf("Unexpected error from readMetadata - expect %v: got %v", errFileNameTooLong, err)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user