Blame SOURCES/dnsmasq-2.80-rh1795370.patch

c1823a
From 69bc94779c2f035a9fffdb5327a54c3aeca73ed5 Mon Sep 17 00:00:00 2001
c1823a
From: Simon Kelley <simon@thekelleys.org.uk>
c1823a
Date: Wed, 14 Aug 2019 20:44:50 +0100
c1823a
Subject: [PATCH] Fix memory leak in helper.c
c1823a
c1823a
Thanks to Xu Mingjie <xumingjie1995@outlook.com> for spotting this.
c1823a
---
c1823a
 src/helper.c |   12 +++++++++---
c1823a
 1 file changed, 9 insertions(+), 3 deletions(-)
c1823a
c1823a
diff --git a/src/helper.c b/src/helper.c
c1823a
index 33ba120..c392eec 100644
c1823a
--- a/src/helper.c
c1823a
+++ b/src/helper.c
c1823a
@@ -80,7 +80,8 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd)
c1823a
   pid_t pid;
c1823a
   int i, pipefd[2];
c1823a
   struct sigaction sigact;
c1823a
-
c1823a
+  unsigned char *alloc_buff = NULL;
c1823a
+  
c1823a
   /* create the pipe through which the main program sends us commands,
c1823a
      then fork our process. */
c1823a
   if (pipe(pipefd) == -1 || !fix_fd(pipefd[1]) || (pid = fork()) == -1)
c1823a
@@ -186,11 +187,16 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd)
c1823a
       struct script_data data;
c1823a
       char *p, *action_str, *hostname = NULL, *domain = NULL;
c1823a
       unsigned char *buf = (unsigned char *)daemon->namebuff;
c1823a
-      unsigned char *end, *extradata, *alloc_buff = NULL;
c1823a
+      unsigned char *end, *extradata;
c1823a
       int is6, err = 0;
c1823a
       int pipeout[2];
c1823a
 
c1823a
-      free(alloc_buff);
c1823a
+      /* Free rarely-allocated memory from previous iteration. */
c1823a
+      if (alloc_buff)
c1823a
+	{
c1823a
+	  free(alloc_buff);
c1823a
+	  alloc_buff = NULL;
c1823a
+	}
c1823a
       
c1823a
       /* we read zero bytes when pipe closed: this is our signal to exit */ 
c1823a
       if (!read_write(pipefd[0], (unsigned char *)&data, sizeof(data), 1))
c1823a
-- 
c1823a
1.7.10.4
c1823a
c1823a