When given oversized key, encrypt/decrypt corrupted

memory.  This fixes it.  Also a free() was missing.

marko
This commit is contained in:
Bruce Momjian 2001-11-08 15:56:58 +00:00
parent 7e16f3c0d8
commit 149d13de74
1 changed files with 4 additions and 1 deletions

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: px.c,v 1.3 2001/10/25 05:49:20 momjian Exp $
* $Id: px.c,v 1.4 2001/11/08 15:56:58 momjian Exp $
*/
#include <postgres.h>
@ -88,6 +88,8 @@ combo_init(PX_Combo * cx, const uint8 *key, uint klen,
memcpy(ivbuf, iv, ivlen);
}
if (klen > ks)
klen = ks;
keybuf = px_alloc(ks);
memset(keybuf, 0, ks);
memcpy(keybuf, key, klen);
@ -96,6 +98,7 @@ combo_init(PX_Combo * cx, const uint8 *key, uint klen,
if (ivbuf)
px_free(ivbuf);
px_free(keybuf);
return err;
}