Skip to content

Commit

Permalink
Fix overflow data conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
didrocks committed Oct 22, 2024
1 parent 7a3eae5 commit 8d1c56e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion internal/authorizer/authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,16 @@ func (a Authorizer) isAllowed(ctx context.Context, action Action, pid int32, uid
return err
}

// polkit requests an uint32 on dbus
var upid uint32
if pid > 0 {
upid = uint32(pid)
}

subject := authSubject{
Kind: "unix-process",
Details: map[string]dbus.Variant{
"pid": dbus.MakeVariant(uint32(pid)), // polkit requests an uint32 on dbus
"pid": dbus.MakeVariant(upid),
"start-time": dbus.MakeVariant(startTime),
"uid": dbus.MakeVariant(uid),
},
Expand Down
4 changes: 2 additions & 2 deletions internal/smbsafe/smbsafe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ func TestMultipleSmbLocksOnlyReleaseOnLast(t *testing.T) {
func shouldHaveWaited(t *testing.T, startpoint time.Time) {
t.Helper()

require.Less(t, uint64(waitTime-time.Millisecond), uint64(time.Since(startpoint)), "Should have waited")
require.Less(t, int64(waitTime-time.Millisecond), int64(time.Since(startpoint)), "Should have waited")
}

func shouldNotHaveWaited(t *testing.T, startpoint time.Time) {
t.Helper()

require.Less(t, uint64(time.Since(startpoint)), uint64(waitTime+time.Millisecond), "Shouldn’t have waited")
require.WithinDuration(t, time.Now(), startpoint, waitTime, "Shouldn’t have waited")
}

0 comments on commit 8d1c56e

Please sign in to comment.