From c91abca157510357126ec447f092af330bfb16ac Mon Sep 17 00:00:00 2001 From: Tudor Golubenco Date: Sun, 29 Oct 2017 23:42:06 +0100 Subject: [PATCH] Fix missing length check in PgSQL (#5457) There was a length check missing. (cherry picked from commit aeca65779d573976981587ca1d1461399e1b59dd) --- CHANGELOG.asciidoc | 2 ++ packetbeat/protos/pgsql/parse.go | 3 +++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index ffe1445402d4..1a5fc1006b20 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -40,6 +40,8 @@ https://github.com/elastic/beats/compare/v6.0.0-rc2...master[Check the HEAD diff *Packetbeat* +- Fix missing length check in the PostgreSQL module. {pull}5457[5457] + *Winlogbeat* ==== Added diff --git a/packetbeat/protos/pgsql/parse.go b/packetbeat/protos/pgsql/parse.go index 10662448dc92..c143241b24fb 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))