From edd2772adc97e2fbb1e44fb2018eef76ba6117e5 Mon Sep 17 00:00:00 2001 From: Fabian Mauchle Date: Tue, 27 Apr 2021 22:30:35 +0200 Subject: [PATCH] check malloc success --- radsecproxy.c | 10 ++++++---- tlscommon.c | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/radsecproxy.c b/radsecproxy.c index a40341e..e8df372 100644 --- a/radsecproxy.c +++ b/radsecproxy.c @@ -841,14 +841,16 @@ int msmppe(unsigned char *attrs, int length, uint8_t type, char *attrtxt, struct int rewriteusername(struct request *rq, struct tlv *attr) { char *orig = (char *)tlv2str(attr); + if (!orig) + return 0; if (!dorewritemodattr(attr, rq->from->conf->rewriteusername)) { - free(orig); - return 0; + free(orig); + return 0; } if (strlen(orig) != attr->l || memcmp(orig, attr->v, attr->l)) - rq->origusername = (char *)orig; + rq->origusername = (char *)orig; else - free(orig); + free(orig); return 1; } diff --git a/tlscommon.c b/tlscommon.c index 53d4671..0bd7da4 100644 --- a/tlscommon.c +++ b/tlscommon.c @@ -1002,6 +1002,7 @@ int addmatchcertattr(struct clsrvconf *conf, const char *match) { } certattrmatch = malloc(sizeof(struct certattrmatch)); + if (!certattrmatch) return 0; memset(certattrmatch, 0, sizeof(struct certattrmatch)); matchcopy = stringcopy(match,0);