relay: fix unsafe overwriting of event buffer that affected parsed pubkeys, ids, content.

This commit is contained in:
fiatjaf
2025-04-07 15:56:36 -03:00
parent 0fc00d8a68
commit dad99b226c

View File

@@ -13,7 +13,6 @@ import (
"sync" "sync"
"sync/atomic" "sync/atomic"
"time" "time"
"unsafe"
"github.com/puzpuzpuz/xsync/v3" "github.com/puzpuzpuz/xsync/v3"
) )
@@ -224,8 +223,7 @@ func (r *Relay) ConnectWithTLS(ctx context.Context, tlsConfig *tls.Config) error
break break
} }
msgb := buf.Bytes() message := string(buf.Bytes())
message := unsafe.String(unsafe.SliceData(msgb), len(msgb))
debugLogf("{%s} received %v\n", r.URL, message) debugLogf("{%s} received %v\n", r.URL, message)
// if this is an "EVENT" we will have this preparser logic that should speed things up a little // if this is an "EVENT" we will have this preparser logic that should speed things up a little