From f5e33d9f50a59c3ff4d8b4823a6ab4fb1412edff Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Sun, 18 Apr 2021 13:49:23 +0200 Subject: [PATCH] headerlist.c: getXMLPackageNFV: fix extending data structures with multiple rich requirements --- src/distromatic.c | 3 +++ src/headerlist.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/distromatic.c b/src/distromatic.c index 2aa585c..f3bee14 100644 --- a/src/distromatic.c +++ b/src/distromatic.c @@ -33,6 +33,7 @@ #include #include #include +#include #if HAVE_UNISTD_H # include @@ -458,6 +459,8 @@ resolveFirstLevelDependencies(struct configTag *ct, int archidx) } // currheader->require.resolved = malloc(sizeof(struct providedList*)*currheader->requirecount); for (i = 0; i < currheader->requirecount; i++) { + assert(currheader->require[i] != NULL); + assert(currheader->require[i]->name != NULL); if (!strncmp("executable(",currheader->require[i]->name,11)) { /* dynamic requirement for executable file */ /*fprintf(stderr,"Warning: skipping unhandled requirement %s for package %s\n", diff --git a/src/headerlist.c b/src/headerlist.c index de79e13..fcaf9d4 100644 --- a/src/headerlist.c +++ b/src/headerlist.c @@ -924,9 +924,9 @@ void getXMLPackageNFV(xmlNode *parent, char ***name, char **newname = malloc(sizeof(char*) * *count); uint_32 *newflags = malloc(sizeof(uint_32) * *count); char **newversion = malloc(sizeof(char*) * *count); - memcpy(newname, *name, sizeof(name)); - memcpy(newflags, *flags, sizeof(flags)); - memcpy(newversion, *version, sizeof(version)); + memcpy(newname, *name, sizeof(char*) * (*count -1)); + memcpy(newflags, *flags, sizeof(uint_32) * (*count - 1)); + memcpy(newversion, *version, sizeof(char*) * (*count - 1)); free(*name); free(*flags); free(*version);