at 18.03-beta 1.4 kB view raw
1From 5bee29fae8f0e936ad4c957aef6035d09532a57a Mon Sep 17 00:00:00 2001 2From: Alon Bar-Lev <alon.barlev@gmail.com> 3Date: Sat, 22 Dec 2012 22:04:27 +0200 4Subject: [PATCH] cleanup: fixup segv on buffer access 5 6use exact buffer size instead of guess. 7 8do not copy out of source buffer. 9 10Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com> 11--- 12 mcrypt-2.6.8/src/rfc2440.c | 5 +++-- 13 1 files changed, 3 insertions(+), 2 deletions(-) 14 15diff --git a/mcrypt-2.6.8/src/rfc2440.c b/mcrypt-2.6.8/src/rfc2440.c 16index 5a1f296..929b9ab 100644 17--- a/src/rfc2440.c 18+++ b/src/rfc2440.c 19@@ -497,7 +497,7 @@ plaintext_encode(const USTRING dat) 20 time_t t; 21 22 assert(dat->len > 0); 23- result = make_ustring( NULL, 2 * dat->len); /* xxx */ 24+ result = make_ustring( NULL, dat->len + 12); /* xxx */ 25 newdat = (USTRING)dat; 26 result->d[pos++] = (0x80 | 0x40 | PKT_PLAINTEXT); 27 28@@ -810,7 +810,8 @@ encrypted_encode(const USTRING pt, const DEK *dek) 29 _mcrypt_encrypt(dek->hd, rndpref, dek->blocklen + 2, NULL, 0); 30 _mcrypt_sync(dek->hd, rndpref, dek->blocklen); 31 32- ct = make_ustring( rndpref, 2 * pt->len); /* xxx */ 33+ ct = make_ustring( NULL, dek->blocklen + 2 + pt->len + 12); /* xxx */ 34+ memcpy(ct->d, rndpref, dek->blocklen + 2); 35 pos = dek->blocklen + 2; 36 37 _mcrypt_encrypt(dek->hd, ct->d + pos, pt->len, pt->d, pt->len); 38-- 391.7.8.6