[dpkg] 77/187: dpkg: Track newargs in a different variable to avoid modifying it

Reiner Herrmann reiner at reiner-h.de
Sun Nov 6 12:46:26 UTC 2016


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

deki-guest pushed a commit to branch master
in repository dpkg.

commit 3b3efd17900415e5ca35ed30caa6d882b36dbc03
Author: Guillem Jover <guillem at debian.org>
Date:   Thu Aug 18 05:18:36 2016 +0200

    dpkg: Track newargs in a different variable to avoid modifying it
    
    The dpkg_options_parse() call modifies the argv argument which means
    that if we try to free it later on or realloc it we will crash.
---
 src/main.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/main.c b/src/main.c
index 4a721b8..97a9985 100644
--- a/src/main.c
+++ b/src/main.c
@@ -777,7 +777,7 @@ commandfd(const char *const *argv)
 {
   struct varbuf linevb = VARBUF_INIT;
   const char * pipein;
-  const char **newargs = NULL;
+  const char **newargs = NULL, **endargs;
   char *ptr, *endptr;
   FILE *in;
   long infd;
@@ -862,12 +862,13 @@ commandfd(const char *const *argv)
     for(i=1;i<argc;i++)
       if (newargs[i])
         newargs[i] = m_strdup(newargs[i]);
+    endargs = newargs;
 
     setaction(NULL, NULL);
-    dpkg_options_parse((const char *const **)&newargs, cmdinfos, printforhelp);
+    dpkg_options_parse((const char *const **)&endargs, cmdinfos, printforhelp);
     if (!cipaction) badusage(_("need an action option"));
 
-    ret |= cipaction->action(newargs);
+    ret |= cipaction->action(endargs);
 
     pop_error_context(ehflag_normaltidy);
   }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list