From 56db6c1c8cf7878e2050eddaba3a5fc7f6845bb8 Mon Sep 17 00:00:00 2001 From: Andrea Barisani Date: Thu, 15 Aug 2024 18:49:28 +0200 Subject: [PATCH] validate applet handler pointers --- trusted_os/rpc.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/trusted_os/rpc.go b/trusted_os/rpc.go index 4b38bb2..fcb3d67 100644 --- a/trusted_os/rpc.go +++ b/trusted_os/rpc.go @@ -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") }