Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/brpc/policy/mysql/mysql_reply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,16 @@ ParseError MysqlReply::Field::Parse(butil::IOBuf& buf,
set_parsed();
return PARSE_OK;
}
// The length-encoded value must fit in the remaining buffer. cutn clamps to
// what is available, so an oversized len leaves the tail of the len-byte
// allocation uninitialized while _data.str is published as len bytes,
// exposing uninitialized arena memory and desyncing the packet stream.
// The binary Field::Parse and Column::Parse paths already guard this.
if (len > buf.size()) {
LOG(WARNING) << "MysqlReply::Field::Parse: field length " << len
<< " exceeds remaining buffer size " << buf.size();
return PARSE_ERROR_ABSOLUTELY_WRONG;
}
// field is not null
butil::IOBuf str;
buf.cutn(&str, len);
Expand Down
Loading