Просмотр исходного кода

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.
Julian Andres Klode лет назад: 10
Родитель
Сommit
950733c947
1 измененных файлов с 11 добавлено и 6 удалено
  1. 11 6
      test/integration/framework

+ 11 - 6
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