Macro argument handling regression (rhbz#455333)
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 16 Jul 2008 06:40:10 +0000 (09:40 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 16 Jul 2008 06:40:10 +0000 (09:40 +0300)
- expandMacro() wants the next \0 character to be returned, which might
  or might not be the same as lastc passed to grabArgs()
- use memcpy() instead of memmove() for the copy, the areas can't overlap

rpmio/macro.c

index 14d4565..cc0638a 100644 (file)
@@ -797,8 +797,10 @@ grabArgs(MacroBuf mb, const rpmMacroEntry me, const char * se,
     {  ARGV_t av = NULL;
        char *s = xcalloc((lastc-se)+1, sizeof(*s));
 
-       memmove(s, se, (lastc-se));
-       ret = se + strlen(s) + 1;
+       /* XXX expandMacro() expects next \0 which can be beyond lastc */
+       ret = strchr(se, '\0');
+       memcpy(s, se, (lastc-se));
+
        argvSplit(&av, s, " ");
        argvAppend(&argv, av);