Fix issues found by ineffassign
gocryptfs$ ineffassign ./... /home/jakob/go/src/github.com/rfjakob/gocryptfs/internal/configfile/config_file.go:243:2: ineffectual assignment to scryptHash /home/jakob/go/src/github.com/rfjakob/gocryptfs/internal/configfile/config_file.go:272:2: ineffectual assignment to scryptHash /home/jakob/go/src/github.com/rfjakob/gocryptfs/internal/fusefrontend/file.go:285:3: ineffectual assignment to fileID /home/jakob/go/src/github.com/rfjakob/gocryptfs/internal/fusefrontend/node.go:367:3: ineffectual assignment to err /home/jakob/go/src/github.com/rfjakob/gocryptfs/internal/fusefrontend/node_open_create.go:68:2: ineffectual assignment to fd /home/jakob/go/src/github.com/rfjakob/gocryptfs/mount.go:308:2: ineffectual assignment to masterkey /home/jakob/go/src/github.com/rfjakob/gocryptfs/gocryptfs-xray/xray_main.go:156:13: ineffectual assignment to err /home/jakob/go/src/github.com/rfjakob/gocryptfs/internal/fusefrontend/prepare_syscall_test.go:65:16: ineffectual assignment to errno /home/jakob/go/src/github.com/rfjakob/gocryptfs/internal/syscallcompat/open_nofollow_test.go:34:2: ineffectual assignment to fd /home/jakob/go/src/github.com/rfjakob/gocryptfs/tests/defaults/acl_test.go:111:6: ineffectual assignment to err /home/jakob/go/src/github.com/rfjakob/gocryptfs/tests/defaults/acl_test.go:181:2: ineffectual assignment to sz /home/jakob/go/src/github.com/rfjakob/gocryptfs/tests/defaults/acl_test.go:198:2: ineffectual assignment to sz /home/jakob/go/src/github.com/rfjakob/gocryptfs/tests/defaults/main_test.go:365:8: ineffectual assignment to err /home/jakob/go/src/github.com/rfjakob/gocryptfs/tests/xattr/xattr_fd_test.go:30:6: ineffectual assignment to err /home/jakob/go/src/github.com/rfjakob/gocryptfs/tests/xattr/xattr_fd_test.go:66:6: ineffectual assignment to err
This commit is contained in:
parent
dc52e32151
commit
64793fedf4
@ -154,10 +154,19 @@ func dumpMasterKey(fn string, fido2Path string) {
|
|||||||
pw = readpassword.Once(nil, nil, "")
|
pw = readpassword.Once(nil, nil, "")
|
||||||
}
|
}
|
||||||
masterkey, err := cf.DecryptMasterKey(pw)
|
masterkey, err := cf.DecryptMasterKey(pw)
|
||||||
fmt.Println(hex.EncodeToString(masterkey))
|
// Purge password from memory
|
||||||
for i := range pw {
|
for i := range pw {
|
||||||
pw[i] = 0
|
pw[i] = 0
|
||||||
}
|
}
|
||||||
|
if err != nil {
|
||||||
|
tlog.Fatal.Println(err)
|
||||||
|
os.Exit(exitcodes.LoadConf)
|
||||||
|
}
|
||||||
|
fmt.Println(hex.EncodeToString(masterkey))
|
||||||
|
// Purge masterkey from memory
|
||||||
|
for i := range masterkey {
|
||||||
|
masterkey[i] = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func inspectCiphertext(fd *os.File, aessiv bool) {
|
func inspectCiphertext(fd *os.File, aessiv bool) {
|
||||||
|
@ -277,16 +277,13 @@ func (f *File) Read(ctx context.Context, buf []byte, off int64) (resultData fuse
|
|||||||
// Empty writes do nothing and are allowed.
|
// Empty writes do nothing and are allowed.
|
||||||
func (f *File) doWrite(data []byte, off int64) (uint32, syscall.Errno) {
|
func (f *File) doWrite(data []byte, off int64) (uint32, syscall.Errno) {
|
||||||
fileWasEmpty := false
|
fileWasEmpty := false
|
||||||
// Get the file ID, create a new one if it does not exist yet.
|
|
||||||
var fileID []byte
|
|
||||||
// The caller has exclusively locked ContentLock, which blocks all other
|
// The caller has exclusively locked ContentLock, which blocks all other
|
||||||
// readers and writers. No need to take IDLock.
|
// readers and writers. No need to take IDLock.
|
||||||
if f.fileTableEntry.ID != nil {
|
//
|
||||||
fileID = f.fileTableEntry.ID
|
// If the file ID is not cached, read it from disk
|
||||||
} else {
|
if f.fileTableEntry.ID == nil {
|
||||||
// If the file ID is not cached, read it from disk
|
|
||||||
var err error
|
var err error
|
||||||
fileID, err = f.readFileID()
|
fileID, err := f.readFileID()
|
||||||
// Write a new file header if the file is empty
|
// Write a new file header if the file is empty
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
fileID, err = f.createHeader()
|
fileID, err = f.createHeader()
|
||||||
|
@ -354,23 +354,25 @@ func (n *Node) Symlink(ctx context.Context, target, name string, out *fuse.Entry
|
|||||||
if !rn.args.PlaintextNames && nametransform.IsLongContent(cName) {
|
if !rn.args.PlaintextNames && nametransform.IsLongContent(cName) {
|
||||||
err = rn.nameTransform.WriteLongNameAt(dirfd, cName, name)
|
err = rn.nameTransform.WriteLongNameAt(dirfd, cName, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errno = fs.ToErrno(err)
|
return nil, fs.ToErrno(err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
// Create "gocryptfs.longfile." symlink
|
// Create "gocryptfs.longfile." symlink
|
||||||
err = syscallcompat.SymlinkatUser(cTarget, dirfd, cName, ctx2)
|
err = syscallcompat.SymlinkatUser(cTarget, dirfd, cName, ctx2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
nametransform.DeleteLongNameAt(dirfd, cName)
|
nametransform.DeleteLongNameAt(dirfd, cName)
|
||||||
|
return nil, fs.ToErrno(err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Create symlink
|
// Create symlink
|
||||||
err = syscallcompat.SymlinkatUser(cTarget, dirfd, cName, ctx2)
|
err = syscallcompat.SymlinkatUser(cTarget, dirfd, cName, ctx2)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fs.ToErrno(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
st, err := syscallcompat.Fstatat2(dirfd, cName, unix.AT_SYMLINK_NOFOLLOW)
|
st, err := syscallcompat.Fstatat2(dirfd, cName, unix.AT_SYMLINK_NOFOLLOW)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errno = fs.ToErrno(err)
|
return nil, fs.ToErrno(err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
// Report the plaintext size, not the encrypted blob size
|
// Report the plaintext size, not the encrypted blob size
|
||||||
st.Size = int64(len(target))
|
st.Size = int64(len(target))
|
||||||
|
@ -63,8 +63,8 @@ func TestPrepareAtSyscall(t *testing.T) {
|
|||||||
syscall.Close(dirfd)
|
syscall.Close(dirfd)
|
||||||
|
|
||||||
dirfd, cName, errno = rn.prepareAtSyscall("dir1")
|
dirfd, cName, errno = rn.prepareAtSyscall("dir1")
|
||||||
if err != nil {
|
if errno != 0 {
|
||||||
t.Fatal(err)
|
t.Fatal(errno)
|
||||||
}
|
}
|
||||||
if cName == "" {
|
if cName == "" {
|
||||||
t.Fatal("cName should not be empty")
|
t.Fatal("cName should not be empty")
|
||||||
|
@ -33,6 +33,7 @@ func TestOpenNofollow(t *testing.T) {
|
|||||||
os.Symlink(tmpDir+"/d1.renamed", tmpDir+"/d1")
|
os.Symlink(tmpDir+"/d1.renamed", tmpDir+"/d1")
|
||||||
fd, err = OpenDirNofollow(tmpDir, "d1/d2/d3")
|
fd, err = OpenDirNofollow(tmpDir, "d1/d2/d3")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
syscall.Close(fd)
|
||||||
t.Fatalf("should have failed")
|
t.Fatalf("should have failed")
|
||||||
}
|
}
|
||||||
if err != syscall.ELOOP && err != syscall.ENOTDIR {
|
if err != syscall.ELOOP && err != syscall.ENOTDIR {
|
||||||
|
@ -109,6 +109,9 @@ func TestAcl543(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
fi, err := os.Stat(fn1)
|
fi, err := os.Stat(fn1)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
if fi.Mode() != modeWant {
|
if fi.Mode() != modeWant {
|
||||||
t.Fatalf("mode changed from %o to %o", modeWant, fi.Mode())
|
t.Fatalf("mode changed from %o to %o", modeWant, fi.Mode())
|
||||||
}
|
}
|
||||||
@ -178,7 +181,7 @@ func TestXattrOverflow(t *testing.T) {
|
|||||||
if sz != len(val) {
|
if sz != len(val) {
|
||||||
t.Errorf("wrong sz: want %d have %d", len(val), sz)
|
t.Errorf("wrong sz: want %d have %d", len(val), sz)
|
||||||
}
|
}
|
||||||
sz, err = unix.Lgetxattr(fn, attr, make([]byte, 1))
|
_, err = unix.Lgetxattr(fn, attr, make([]byte, 1))
|
||||||
if err != syscall.ERANGE {
|
if err != syscall.ERANGE {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@ -195,7 +198,7 @@ func TestXattrOverflow(t *testing.T) {
|
|||||||
if sz != szWant {
|
if sz != szWant {
|
||||||
t.Errorf("wrong sz: want %d have %d", szWant, sz)
|
t.Errorf("wrong sz: want %d have %d", szWant, sz)
|
||||||
}
|
}
|
||||||
sz, err = unix.Llistxattr(fn, make([]byte, 1))
|
_, err = unix.Llistxattr(fn, make([]byte, 1))
|
||||||
if err != syscall.ERANGE {
|
if err != syscall.ERANGE {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
@ -363,6 +363,9 @@ func TestMd5sumMaintainers(t *testing.T) {
|
|||||||
|
|
||||||
cmd := exec.Command("md5sum", fn, fn, fn, fn)
|
cmd := exec.Command("md5sum", fn, fn, fn, fn)
|
||||||
out2, err := cmd.CombinedOutput()
|
out2, err := cmd.CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
out := string(out2)
|
out := string(out2)
|
||||||
|
|
||||||
// 195191 zero bytes have this md5sum
|
// 195191 zero bytes have this md5sum
|
||||||
|
@ -28,7 +28,9 @@ func TestFdXattr(t *testing.T) {
|
|||||||
defer syscall.Close(fd)
|
defer syscall.Close(fd)
|
||||||
buf := make([]byte, 1000)
|
buf := make([]byte, 1000)
|
||||||
sz, err := unix.Flistxattr(fd, buf)
|
sz, err := unix.Flistxattr(fd, buf)
|
||||||
if sz != 0 {
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
} else if sz != 0 {
|
||||||
t.Errorf("expected zero size, got %d", sz)
|
t.Errorf("expected zero size, got %d", sz)
|
||||||
}
|
}
|
||||||
val1 := []byte("123456789")
|
val1 := []byte("123456789")
|
||||||
@ -64,7 +66,9 @@ func TestFdXattr(t *testing.T) {
|
|||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
sz, err = unix.Flistxattr(fd, buf)
|
sz, err = unix.Flistxattr(fd, buf)
|
||||||
if sz != 0 {
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
} else if sz != 0 {
|
||||||
t.Errorf("expected zero size, got %d", sz)
|
t.Errorf("expected zero size, got %d", sz)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user