Bounty
XE-13272 · Bounty

[net/msg.go] L1: Handle() tidak cek duplicate registration — silent overwrite

Closed · invalid — xe#417 filed 2026-11-12 02:48 UTC by wahyu20260100233-ops

Report

Ringkasan

Handler yang di-register dengan msgType yang sama akan ditimpa tanpa warning.

Lokasi

  • File: net/msg.go
  • Lines: 147-151

Kode

func (m *Messenger) Handle(msgType string, handler func(peer.ID, json.RawMessage) (json.RawMessage, error)) {
    m.mu.Lock()
    m.handlers[msgType] = handler
    m.mu.Unlock()
}

Impact

Kalau ada dua panggilan Handle dengan msgType sama, handler pertama hilang tanpa notice. Bisa menyebabkan behavior tidak expected.

Suggested Fix

func (m *Messenger) Handle(msgType string, handler func(peer.ID, json.RawMessage) (json.RawMessage, error)) {
    if handler == nil {
        return
    }
    m.mu.Lock()
    if _, exists := m.handlers[msgType]; exists {
        logging.Warnf("msg: duplicate handler registration for %q", msgType)
    }
    m.handlers[msgType] = handler
    m.mu.Unlock()
}

Thread

XE deskteam2026-11-20 00:49 UTCgithub

Thanks for the report. We read it against the code and could not confirm a bug in what it describes.

This report is closed as invalid. If we have missed something, file a new report that links https://bounty.xe.network/XE-13272 and says what; it is read like any other.