]> git.ipfire.org Git - thirdparty/asterisk.git/commit
cel_pgsql.c: Fix buffer overflow calling libpq
authorJosh Roberson <josh@asteriasgi.com>
Mon, 27 Mar 2017 16:49:08 +0000 (11:49 -0500)
committertwisted <josh@asteriasgi.com>
Wed, 29 Mar 2017 13:53:43 +0000 (07:53 -0600)
commit43c785545be6402027a47f3ebae095bffc30eca7
tree747e9af5eaa370b1def906640c015a2a64599ac2
parentf719c661a2113291b53e9b8e7002aba5d09ce92b
cel_pgsql.c: Fix buffer overflow calling libpq

PQEscapeStringConn() expects the buffer passed in to be an
adequitely sized buffer to write out the escaped SQL value string
into.  It is possible, for large values (such as large values to
Dial with a lot of devices) to have more than our 512+1 byte
allocation and thus cause libpq to create a buffer overrun.

glibc will nicely ABRT asterisk for you, citing a stack smash.

Let's only allocate it to be as large as needed:
If we have a value, then (strlen(value) * 2) + 1 (as recommended
by libpq), and if we have none, just one byte to hold our null
will do.

ASTERISK-26896 #close

Change-Id: If611c734292618ed68dde17816d09dd16667dea2
cel/cel_pgsql.c