[Pkg-privacy-commits] [libotr] 03/06: One more otrl_base64_decode in the toolkit

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 12:46:08 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to tag release_3_2_1
in repository libotr.

commit 1902baee5d4b056850274ed0fa8c2409f1187435
Author: Ian Goldberg <iang at cs.uwaterloo.ca>
Date:   Thu Jul 19 10:50:44 2012 -0400

    One more otrl_base64_decode in the toolkit
---
 toolkit/parse.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/toolkit/parse.c b/toolkit/parse.c
index 5f357fc..16718ca 100644
--- a/toolkit/parse.c
+++ b/toolkit/parse.c
@@ -64,7 +64,8 @@ static unsigned char *decode(const char *msg, size_t *lenp)
 {
     const char *header, *footer;
     unsigned char *raw;
-	
+    size_t rawlen;
+
     /* Find the header */
     header = strstr(msg, "?OTR:");
     if (!header) return NULL;
@@ -75,8 +76,10 @@ static unsigned char *decode(const char *msg, size_t *lenp)
     footer = strchr(header, '.');
     if (!footer) footer = header + strlen(header);
 
-    raw = malloc((footer-header) / 4 * 3);
-    if (raw == NULL && (footer-header >= 4)) return NULL;
+    rawlen = OTRL_B64_MAX_DECODED_SIZE(footer-header);
+
+    raw = malloc(rawlen);
+    if (raw == NULL && rawlen > 0) return NULL;
     *lenp = otrl_base64_decode(raw, header, footer-header);
 
     return raw;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/libotr.git



More information about the Pkg-privacy-commits mailing list