From 950733c947acd50afe498e900954d911454c57e7 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 14 Dec 2015 13:39:52 +0100 Subject: test framework: More noopchroot fixes Use asprintf() so we have easy error detection and do not depend on PATH_MAX. Do not add another separator to the generated path, in both cases the path inside the chroot is guaranteed to have a leading / already. Also pass -Wall to gcc. --- test/integration/framework | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/integration/framework b/test/integration/framework index ee976aff5..d52fcdf87 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -478,7 +478,6 @@ configdpkgnoopchroot() { #include #include #include -#include static char * chrootdir = NULL; @@ -495,16 +494,22 @@ int execvp(const char *file, char *const argv[]) { if (chrootdir == NULL || strncmp(file, "/var/lib/dpkg/", strlen("/var/lib/dpkg/")) != 0) return func_execvp(file, argv); printf("REWRITE execvp call %s into %s\n", file, chrootdir); - char newfile[PATH_MAX]; - snprintf(newfile, sizeof(newfile), "%s/%s", chrootdir, file); + char *newfile; + if (asprintf(&newfile, "%s%s", chrootdir, file) == -1) { + perror("asprintf"); + return -1; + } char const * const baseadmindir = "/var/lib/dpkg"; - char admindir[PATH_MAX]; - snprintf(admindir, sizeof(admindir), "%s/%s", chrootdir, baseadmindir); + char *admindir; + if (asprintf(&admindir, "%s%s", chrootdir, baseadmindir) == -1) { + perror("asprintf"); + return -1; + } setenv("DPKG_ADMINDIR", admindir, 1); return func_execvp(newfile, argv); } EOF - testsuccess --nomsg gcc -fPIC -shared -o noopchroot.so noopchroot.c -ldl + testsuccess --nomsg gcc -Wall -fPIC -shared -o noopchroot.so noopchroot.c -ldl } configcompression() { while [ -n "$1" ]; do -- cgit v1.2.3