]> 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)
committerSean Bright <sean.bright@gmail.com>
Mon, 27 Mar 2017 19:51:44 +0000 (15:51 -0400)
commitbb68f57a03c0639663aa20d95fcdc16a4c1ff094
treebe012b8ca632b95c66d568a13c69b9a88f39f9a5
parent552cf009c0939c8b6597708135412bdc596df4bb
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