Patch from Marko Kreen:
Patch from Marko Kreen:

pgcrypto crypt()/md5 and hmac() leak memory when compiled against
OpenSSL as openssl.c digest ->reset will do two DigestInit calls
against a context.  This happened to work with OpenSSL 0.9.6
but not with 0.9.7+.

Reason for the messy code was that I tried to avoid creating
wrapper structure to transport algorithm info and tried to use
OpenSSL context for it.  The fix is to create wrapper structure.

It also uses newer digest API to avoid memory allocations
on reset with newer OpenSSLs.

Thanks to Daniel Blaisdell for reporting it.

postmind-net/postgres-xl,Quikling/gpdb,randomtask1155/gpdb,tangp3/gpdb,foyzur/gpdb,randomtask1155/gpdb,yuanzhao/gpdb,Quikling/gpdb,arcivanov/postgres-xl,randomtask1155/gpdb,ashwinstar/gpdb,tangp3/gpdb,50wu/gpdb,Chibin/gpdb,zaksoup/gpdb,edespino/gpdb,greenplum-db/gpdb,randomtask1155/gpdb,lisakowen/gpdb,jmcatamney/gpdb,Chibin/gpdb,xinzweb/gpdb,edespino/gpdb,yuanzhao/gpdb,cjcjameson/gpdb,lintzc/gpdb,cjcjameson/gpdb,chrishajas/gpdb,rvs/gpdb,atris/gpdb,pavanvd/postgres-xl,janebeckman/gpdb,0x0FFF/gpdb,arcivanov/postgres-xl,greenplum-db/gpdb,snaga/postgres-xl,Chibin/gpdb,lisakowen/gpdb,50wu/gpdb,zaksoup/gpdb,royc1/gpdb,Postgres-XL/Postgres-XL,royc1/gpdb,Quikling/gpdb,CraigHarris/gpdb,yuanzhao/gpdb,rubikloud/gpdb,royc1/gpdb,techdragon/Postgres-XL,atris/gpdb,oberstet/postgres-xl,randomtask1155/gpdb,kaknikhil/gpdb,kaknikhil/gpdb,xuegang/gpdb,cjcjameson/gpdb,ashwinstar/gpdb,greenplum-db/gpdb,xinzweb/gpdb,kaknikhil/gpdb,ovr/postgres-xl,jmcatamney/gpdb,rvs/gpdb,techdragon/Postgres-XL,postmind-net/postgres-xl,lpetrov-pivotal/gpdb,adam8157/gpdb,ahachete/gpdb,arcivanov/postgres-xl,CraigHarris/gpdb,CraigHarris/gpdb,zaksoup/gpdb,chrishajas/gpdb,greenplum-db/gpdb,kaknikhil/gpdb,oberstet/postgres-xl,50wu/gpdb,ahachete/gpdb,cjcjameson/gpdb,kaknikhil/gpdb,royc1/gpdb,randomtask1155/gpdb,zaksoup/gpdb,janebeckman/gpdb,Postgres-XL/Postgres-XL,lintzc/gpdb,50wu/gpdb,rvs/gpdb,chrishajas/gpdb,Quikling/gpdb,Quikling/gpdb,rubikloud/gpdb,Quikling/gpdb,tpostgres-projects/tPostgres,cjcjameson/gpdb,edespino/gpdb,cjcjameson/gpdb,xuegang/gpdb,xinzweb/gpdb,foyzur/gpdb,adam8157/gpdb,yazun/postgres-xl,rvs/gpdb,kmjungersen/PostgresXL,CraigHarris/gpdb,janebeckman/gpdb,CraigHarris/gpdb,CraigHarris/gpdb,ashwinstar/gpdb,Quikling/gpdb,tangp3/gpdb,ahachete/gpdb,techdragon/Postgres-XL,pavanvd/postgres-xl,rvs/gpdb,Postgres-XL/Postgres-XL,foyzur/gpdb,foyzur/gpdb,arcivanov/postgres-xl,Chibin/gpdb,janebeckman/gpdb,oberstet/postgres-xl,xuegang/gpdb,tangp3/gpdb,yuanzhao/gpdb,50wu/gpdb,tangp3/gpdb,zeroae/postgres-xl,kmjungersen/PostgresXL,royc1/gpdb,tpostgres-projects/tPostgres,zaksoup/gpdb,cjcjameson/gpdb,edespino/gpdb,edespino/gpdb,kaknikhil/gpdb,kaknikhil/gpdb,edespino/gpdb,kmjungersen/PostgresXL,adam8157/gpdb,cjcjameson/gpdb,rubikloud/gpdb,tpostgres-projects/tPostgres,yazun/postgres-xl,jmcatamney/gpdb,pavanvd/postgres-xl,jmcatamney/gpdb,lintzc/gpdb,ahachete/gpdb,yuanzhao/gpdb,ahachete/gpdb,kaknikhil/gpdb,yazun/postgres-xl,CraigHarris/gpdb,Quikling/gpdb,xinzweb/gpdb,Chibin/gpdb,xuegang/gpdb,zeroae/postgres-xl,0x0FFF/gpdb,0x0FFF/gpdb,arcivanov/postgres-xl,yuanzhao/gpdb,yuanzhao/gpdb,50wu/gpdb,0x0FFF/gpdb,lpetrov-pivotal/gpdb,foyzur/gpdb,oberstet/postgres-xl,pavanvd/postgres-xl,ashwinstar/gpdb,greenplum-db/gpdb,Chibin/gpdb,lintzc/gpdb,xuegang/gpdb,lintzc/gpdb,Postgres-XL/Postgres-XL,atris/gpdb,janebeckman/gpdb,Quikling/gpdb,lisakowen/gpdb,edespino/gpdb,cjcjameson/gpdb,CraigHarris/gpdb,royc1/gpdb,lpetrov-pivotal/gpdb,postmind-net/postgres-xl,zeroae/postgres-xl,xuegang/gpdb,lintzc/gpdb,adam8157/gpdb,lpetrov-pivotal/gpdb,zaksoup/gpdb,adam8157/gpdb,xinzweb/gpdb,tangp3/gpdb,lisakowen/gpdb,foyzur/gpdb,ovr/postgres-xl,edespino/gpdb,postmind-net/postgres-xl,lpetrov-pivotal/gpdb,greenplum-db/gpdb,greenplum-db/gpdb,techdragon/Postgres-XL,snaga/postgres-xl,chrishajas/gpdb,janebeckman/gpdb,rvs/gpdb,yazun/postgres-xl,0x0FFF/gpdb,50wu/gpdb,arcivanov/postgres-xl,ashwinstar/gpdb,lisakowen/gpdb,atris/gpdb,snaga/postgres-xl,jmcatamney/gpdb,royc1/gpdb,randomtask1155/gpdb,tpostgres-projects/tPostgres,Chibin/gpdb,rvs/gpdb,lintzc/gpdb,atris/gpdb,Postgres-XL/Postgres-XL,rubikloud/gpdb,jmcatamney/gpdb,edespino/gpdb,rubikloud/gpdb,rubikloud/gpdb,ashwinstar/gpdb,zaksoup/gpdb,oberstet/postgres-xl,rvs/gpdb,rubikloud/gpdb,lpetrov-pivotal/gpdb,atris/gpdb,xinzweb/gpdb,yazun/postgres-xl,janebeckman/gpdb,lisakowen/gpdb,Chibin/gpdb,yuanzhao/gpdb,lintzc/gpdb,chrishajas/gpdb,chrishajas/gpdb,ahachete/gpdb,janebeckman/gpdb,foyzur/gpdb,janebeckman/gpdb,ahachete/gpdb,yuanzhao/gpdb,jmcatamney/gpdb,xuegang/gpdb,chrishajas/gpdb,tpostgres-projects/tPostgres,zeroae/postgres-xl,yuanzhao/gpdb,ashwinstar/gpdb,snaga/postgres-xl,atris/gpdb,adam8157/gpdb,rubikloud/gpdb,edespino/gpdb,50wu/gpdb,kaknikhil/gpdb,postmind-net/postgres-xl,ovr/postgres-xl,kmjungersen/PostgresXL,ovr/postgres-xl,xuegang/gpdb,rvs/gpdb,lpetrov-pivotal/gpdb,foyzur/gpdb,atris/gpdb,0x0FFF/gpdb,kmjungersen/PostgresXL,ahachete/gpdb,greenplum-db/gpdb,0x0FFF/gpdb,xinzweb/gpdb,jmcatamney/gpdb,lisakowen/gpdb,snaga/postgres-xl,Chibin/gpdb,adam8157/gpdb,zeroae/postgres-xl,cjcjameson/gpdb,Quikling/gpdb,techdragon/Postgres-XL,tangp3/gpdb,lintzc/gpdb,pavanvd/postgres-xl,rvs/gpdb,lpetrov-pivotal/gpdb,xinzweb/gpdb,adam8157/gpdb,xuegang/gpdb,royc1/gpdb,Chibin/gpdb,ashwinstar/gpdb,chrishajas/gpdb,janebeckman/gpdb,0x0FFF/gpdb,randomtask1155/gpdb,CraigHarris/gpdb,kaknikhil/gpdb,zaksoup/gpdb,lisakowen/gpdb,ovr/postgres-xl,tangp3/gpdb