diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 84212d07749..429e4b0e549 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -64,6 +64,7 @@ https://github.com/elastic/beats/compare/v6.0.0-beta2...master[Check the HEAD di *Packetbeat* - Fix http status phrase parsing not allow spaces. {pull}5312[5312] +- Fix missing length check in the PostgreSQL module. {pull}5457[5457] *Winlogbeat* diff --git a/packetbeat/protos/pgsql/parse.go b/packetbeat/protos/pgsql/parse.go index 10662448dc9..c143241b24f 100644 --- a/packetbeat/protos/pgsql/parse.go +++ b/packetbeat/protos/pgsql/parse.go @@ -377,6 +377,9 @@ func pgsqlFieldsParser(s *pgsqlStream, buf []byte) error { off += 4 // read format (int16) + if len(buf) < off+2 { + return errFieldBufferShort + } format := common.BytesNtohs(buf[off : off+2]) off += 2 fieldsFormat = append(fieldsFormat, byte(format))