From 366b3a85e910741678c84a26b1765d0a3c918c05 Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Thu, 4 Dec 2025 17:32:34 +0100 Subject: [PATCH] Fix WriteBytes/WriteString/WriteStringFromBytes limit --- msgp/write.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/msgp/write.go b/msgp/write.go index d4e88089..55192222 100644 --- a/msgp/write.go +++ b/msgp/write.go @@ -448,7 +448,7 @@ func (mw *Writer) WriteUint(u uint) error { return mw.WriteUint64(uint64(u)) } // WriteBytes writes binary as 'bin' to the writer func (mw *Writer) WriteBytes(b []byte) error { - if uint64(len(b)) > math.MaxInt32 { + if uint64(len(b)) > math.MaxUint32 { return ErrLimitExceeded } sz := uint32(len(b)) @@ -493,7 +493,7 @@ func (mw *Writer) WriteBool(b bool) error { // WriteString writes a messagepack string to the writer. // (This is NOT an implementation of io.StringWriter) func (mw *Writer) WriteString(s string) error { - if uint64(len(s)) > math.MaxInt32 { + if uint64(len(s)) > math.MaxUint32 { return ErrLimitExceeded } @@ -535,7 +535,7 @@ func (mw *Writer) WriteStringHeader(sz uint32) error { // WriteStringFromBytes writes a 'str' object // from a []byte. func (mw *Writer) WriteStringFromBytes(str []byte) error { - if uint64(len(str)) > math.MaxInt32 { + if uint64(len(str)) > math.MaxUint32 { return ErrLimitExceeded } sz := uint32(len(str))