From 260eec04d51fd986f895b676554b1ff6a1799417 Mon Sep 17 00:00:00 2001 From: BALATON Zoltan Date: Thu, 13 Jul 2017 01:57:58 +0200 Subject: activation: Fix wrong argument check of plist_strip_xml() This also fixes a potential segfault when xmlplist is NULL and adds check for failing to allocate memory. --- src/activation.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/activation.c b/src/activation.c index ddc924f..72e6ee7 100644 --- a/src/activation.c +++ b/src/activation.c @@ -610,22 +610,23 @@ static int plist_strip_xml(char** xmlplist) { uint32_t size = 0; - if (!xmlplist && !*xmlplist) + if (!xmlplist || !*xmlplist) return -1; char* start = strstr(*xmlplist, "\n"); - if (start == NULL) { + if (!start) return -1; - } char* stop = strstr(*xmlplist, "\n"); - if (stop == NULL) { + if (!stop) return -1; - } start += strlen("\n"); size = stop - start; char* stripped = malloc(size + 1); + if (!stripped) + return -1; + memset(stripped, '\0', size + 1); memcpy(stripped, start, size); free(*xmlplist); -- cgit v1.1-32-gdbae