From 66183bc7c7ae0d3f367c08f4e7476c4cbcd459cd Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Thu, 9 Nov 2017 18:51:29 +0000 Subject: [PATCH] output: make mustach processing more robust Fix issues found with afl-fuzz. It is a pity I had to change mustach.c it is no longer exactly the same as upstream. Lets see if Jose will accept these changes. Signed-off-by: Sami Kerola --- src/mustach.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mustach.c b/src/mustach.c index 9868cff..e2da8b2 100644 --- a/src/mustach.c +++ b/src/mustach.c @@ -38,7 +38,7 @@ static int getpartial(struct mustach_itf *itf, void *closure, const char *name, *result = NULL; file = open_memstream(result, &size); - if (file == NULL) + if (itf->put == NULL || file == NULL) rc = MUSTACH_ERROR_SYSTEM; else { rc = itf->put(closure, name, 0, file); @@ -192,6 +192,8 @@ static int process(const char *template, struct mustach_itf *itf, void *closure, default: /* replacement */ if (emit) { + if (itf->put == NULL) + return MUSTACH_ERROR_SYSTEM; rc = itf->put(closure, name, c != '&', file); if (rc < 0) return rc;