summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2015-12-14 13:39:52 +0100
committerJulian Andres Klode <jak@debian.org>2015-12-14 13:40:39 +0100
commit950733c947acd50afe498e900954d911454c57e7 (patch)
treeacd1b5e981994539cf8183ac1ac3521577372852
parent59f57473ab85d3fb3354d086db2df2466c1c3896 (diff)
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.
-rw-r--r--test/integration/framework17
1 files changed, 11 insertions, 6 deletions
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 <stdlib.h>
#include <string.h>
#include <dlfcn.h>
-#include <limits.h>
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