$OpenBSD: patch-src_rfc2440_c,v 1.1 2013/05/18 20:00:43 benoit Exp $

- fix segv : http://sourceforge.net/p/mcrypt/patches/13/

--- src/rfc2440.c.orig	Sun Nov 16 20:50:01 2008
+++ src/rfc2440.c	Sat May 18 17:22:25 2013
@@ -497,7 +497,7 @@
     time_t t;
 
     assert(dat->len > 0);
-    result = make_ustring( NULL,  2 * dat->len); /* xxx */
+    result = make_ustring( NULL,  dat->len + 12); /* xxx */
     newdat = (USTRING)dat;
     result->d[pos++] = (0x80 | 0x40 | PKT_PLAINTEXT);
 
@@ -810,7 +810,8 @@
     _mcrypt_encrypt(dek->hd, rndpref, dek->blocklen + 2, NULL, 0);
     _mcrypt_sync(dek->hd, rndpref, dek->blocklen);
 
-    ct = make_ustring( rndpref,   2 * pt->len); /* xxx */
+    ct = make_ustring( NULL, dek->blocklen + 2 + pt->len + 12); /* xxx */
+    memcpy(ct->d, rndpref, dek->blocklen + 2);
     pos = dek->blocklen + 2;
     
     _mcrypt_encrypt(dek->hd, ct->d + pos, pt->len, pt->d, pt->len);
