diff options
| author | Jakob Unterwurzacher | 2018-01-25 22:22:13 +0100 | 
|---|---|---|
| committer | Jakob Unterwurzacher | 2018-01-25 22:22:13 +0100 | 
| commit | f3838c09d841ebdb071981e190c7579e61ee057f (patch) | |
| tree | 89960507e0cb8bf1143d0afae97f91ed248d6f38 | |
| parent | b3185723129725b1b5557912eb323e55033d8f67 (diff) | |
syscallcompat: hardcode maxReclen = 280 for all architectures
Due to padding between entries, it is 280 even on 32-bit architectures.
See https://github.com/rfjakob/gocryptfs/issues/197 for details.
| -rw-r--r-- | internal/syscallcompat/getdents_linux.go | 9 | 
1 files changed, 7 insertions, 2 deletions
| diff --git a/internal/syscallcompat/getdents_linux.go b/internal/syscallcompat/getdents_linux.go index aaa69ac..146517c 100644 --- a/internal/syscallcompat/getdents_linux.go +++ b/internal/syscallcompat/getdents_linux.go @@ -21,6 +21,11 @@ import (  const sizeofDirent = int(unsafe.Sizeof(syscall.Dirent{})) +// maxReclen sanity check: Reclen should never be larger than this. +// Due to padding between entries, it is 280 even on 32-bit architectures. +// See https://github.com/rfjakob/gocryptfs/issues/197 for details. +const maxReclen = 280 +  // getdents wraps syscall.Getdents and converts the result to []fuse.DirEntry.  func getdents(fd int) ([]fuse.DirEntry, error) {  	// Collect syscall result in smartBuf. @@ -53,9 +58,9 @@ func getdents(fd int) ([]fuse.DirEntry, error) {  			// EBADR = Invalid request descriptor  			return nil, syscall.EBADR  		} -		if int(s.Reclen) > sizeofDirent { +		if int(s.Reclen) > maxReclen {  			tlog.Warn.Printf("Getdents: corrupt entry #%d: Reclen=%d > %d. Returning EBADR", -				numEntries, s.Reclen, sizeofDirent) +				numEntries, s.Reclen, maxReclen)  			return nil, syscall.EBADR  		}  		offset += int(s.Reclen) | 
