From 1c56622cded1d9c4a9c23d34a5bfa711e11cf299 Mon Sep 17 00:00:00 2001 From: Simone Margaritelli Date: Tue, 27 Aug 2024 09:25:40 +0200 Subject: [PATCH] fix: can.fuzz now expects an hexadecimal frame id (thanks musafir) --- modules/can/can.go | 2 +- modules/can/can_fuzz.go | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/can/can.go b/modules/can/can.go index d47dc8dc..8ee30041 100644 --- a/modules/can/can.go +++ b/modules/can/can.go @@ -102,7 +102,7 @@ func NewCanModule(s *session.Session) *CANModule { })) mod.AddHandler(session.NewModuleHandler("can.fuzz ID_OR_NODE_NAME", `(?i)^can\.fuzz\s+(.+)$`, - "If an integer frame ID is specified, create a randomized version of it and inject it. If a node name is specified, a random message for the given node will be instead used.", + "If an hexadecimal frame ID is specified, create a randomized version of it and inject it. If a node name is specified, a random message for the given node will be instead used.", func(args []string) error { if !mod.Running() { return errors.New("can module not running") diff --git a/modules/can/can_fuzz.go b/modules/can/can_fuzz.go index 626c0cfd..ba557da0 100644 --- a/modules/can/can_fuzz.go +++ b/modules/can/can_fuzz.go @@ -16,8 +16,9 @@ func (mod *CANModule) Fuzz(id string) error { rncSource := rand.NewSource(time.Now().Unix()) rng := rand.New(rncSource) - // let's try as number first - frameID, err := strconv.Atoi(id) + // let's try as an hex number first + // frameID, err := strconv.Atoi(id) + frameID, err := strconv.ParseUint(id, 16, 32) dataLen := 0 frameData := ([]byte)(nil) @@ -32,7 +33,7 @@ func (mod *CANModule) Fuzz(id string) error { idx := rng.Intn(len(fromSender)) selected := fromSender[idx] mod.Info("selected %s > (%d) %s", id, selected.ID, selected.Name) - frameID = int(selected.ID) + frameID = uint64(selected.ID) } else { return err }