Skip to content

Commit

Permalink
validate applet handler pointers (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
abarisani authored Aug 16, 2024
1 parent 4aaa133 commit 5fd3b4a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion trusted_os/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,13 @@ func (r *RPC) Address(mac net.HardwareAddr, _ *bool) error {
return nil
}

func isAppletMemory(addr uint32) bool {
return addr >= appletStart && addr < appletStart + appletSize
}

// Register registers the Trusted Applet event handler.
func (r *RPC) Register(handler rpc.Handler, _ *bool) error {
if handler.G == 0 || handler.P == 0 {
if !isAppletMemory(handler.G) || !isAppletMemory(handler.P) {
return errors.New("invalid argument")
}

Expand Down

0 comments on commit 5fd3b4a

Please sign in to comment.