[Pkg-privacy-commits] [libotr] 10/20: Fix memory leak in otrl_instag_read_FILEp if the tag file is malformed

Intrigeri intrigeri at moszumanska.debian.org
Thu Mar 10 09:25:58 UTC 2016


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

intrigeri pushed a commit to annotated tag 4.1.1
in repository libotr.

commit aa6b7053561e9a2bcc4ca9af761fdfbec6ad7adf
Author: Ian Goldberg <iang at cs.uwaterloo.ca>
Date:   Fri Dec 25 13:30:31 2015 -0500

    Fix memory leak in otrl_instag_read_FILEp if the tag file is malformed
    
    Thanks to Jean-Philippe Aumasson <jeanphilippe.aumasson at gmail.com> for the report.
    
    Signed-off-by: Ian Goldberg <iang at cs.uwaterloo.ca>
    Signed-off-by: David Goulet <dgoulet at ev0ke.net>
---
 src/instag.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/instag.c b/src/instag.c
index 8878007..8e92cc3 100644
--- a/src/instag.c
+++ b/src/instag.c
@@ -117,23 +117,35 @@ gcry_error_t otrl_instag_read_FILEp(OtrlUserState us, FILE *instf)
 	*pos = '\0';
 	pos++;
 	p->accountname = malloc(pos - prevpos);
+	if (!(p->accountname)) {
+	    free(p);
+	    return gcry_error(GPG_ERR_ENOMEM);
+	}
 	memmove(p->accountname, prevpos, pos - prevpos);
 
 	prevpos = pos;
 	pos = strchr(prevpos, '\t');
 	if (!pos) {
+	    free(p->accountname);
 	    free(p);
 	    continue;
 	}
 	*pos = '\0';
 	pos++;
 	p->protocol = malloc(pos - prevpos);
+	if (!(p->protocol)) {
+	    free(p->accountname);
+	    free(p);
+	    return gcry_error(GPG_ERR_ENOMEM);
+	}
 	memmove(p->protocol, prevpos, pos - prevpos);
 
 	prevpos = pos;
 	pos = strchr(prevpos, '\r');
 	if (!pos) pos = strchr(prevpos, '\n');
 	if (!pos) {
+	    free(p->accountname);
+	    free(p->protocol);
 	    free(p);
 	    continue;
 	}
@@ -141,6 +153,8 @@ gcry_error_t otrl_instag_read_FILEp(OtrlUserState us, FILE *instf)
 	pos++;
 	/* hex str of length 8 */
 	if (strlen(prevpos) != 8) {
+	    free(p->accountname);
+	    free(p->protocol);
 	    free(p);
 	    continue;
 	}
@@ -148,6 +162,8 @@ gcry_error_t otrl_instag_read_FILEp(OtrlUserState us, FILE *instf)
 	sscanf(prevpos, "%08x", &instag);
 
 	if (instag < OTRL_MIN_VALID_INSTAG) {
+	    free(p->accountname);
+	    free(p->protocol);
 	    free(p);
 	    continue;
 	}

-- 
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