fiorix / go-diameter

Diameter stack and Base Protocol (RFC 6733) for the Go programming language
Other
244 stars 141 forks source link

Make AVP decoding goroutine-safe #186

Open higebu opened 9 months ago

higebu commented 9 months ago

Fixes #140

A read buffer will be reused when diam.ReadMessage() finishes. However, the byte slice in the read buffer will remain. This is because the byte slice is not copied during the decoding of AVPs. Therefore, when trying to read diam.Message.AVP after diam.ReadMessage() has completed, a race condition occurs if the read buffer has already been reused.

https://github.com/fiorix/go-diameter/blob/3ddd9fb50b0a96dfd0bedb87f46afdd91d66556f/diam/message.go#L67-L80