diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-11-10 14:57:46 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-11-10 14:57:46 +0000 |
commit | af9b481653240fe1ffd66f184026ea24928abcb2 (patch) | |
tree | fbde31e65ad77e3e8418e44758b4467718d9207e | |
parent | d0d2d74ce73e733b8cb1868a37a033d498aae0c3 (diff) | |
download | postgresql-af9b481653240fe1ffd66f184026ea24928abcb2.tar.gz postgresql-af9b481653240fe1ffd66f184026ea24928abcb2.zip |
Fix old bug in contrib/sslinfo: X509_NAME_to_text freed the BIO_s_mem buffer
it was using too soon. In a situation where pg_do_encoding_conversion is
a no-op, this led to garbage data returned.
In HEAD, also modify the code that's ensuring null termination to make it
a tad more obvious what's happening.
-rw-r--r-- | contrib/sslinfo/sslinfo.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/contrib/sslinfo/sslinfo.c b/contrib/sslinfo/sslinfo.c index 7236203d7d8..926877fdef9 100644 --- a/contrib/sslinfo/sslinfo.c +++ b/contrib/sslinfo/sslinfo.c @@ -4,7 +4,7 @@ * Written by Victor B. Wagner <vitus@cryptocom.ru>, Cryptocom LTD * This file is distributed under BSD-style license. * - * $PostgreSQL: pgsql/contrib/sslinfo/sslinfo.c,v 1.6 2007/02/27 23:48:06 tgl Exp $ + * $PostgreSQL: pgsql/contrib/sslinfo/sslinfo.c,v 1.6.2.1 2008/11/10 14:57:46 tgl Exp $ */ #include "postgres.h" @@ -312,19 +312,14 @@ X509_NAME_to_text(X509_NAME *name) size - 1, PG_UTF8, GetDatabaseEncoding()); - BIO_free(membuf); - outlen = strlen(dp); result = palloc(VARHDRSZ + outlen); memcpy(VARDATA(result), dp, outlen); SET_VARSIZE(result, VARHDRSZ + outlen); - /* - * pg_do_encoding_conversion has annoying habit of returning source - * pointer - */ if (dp != sp) pfree(dp); + BIO_free(membuf); PG_RETURN_TEXT_P(result); } |