]> git.saurik.com Git - apt.git/blobdiff - test/integration/framework
test framework: Correctly generate new paths in noopchroot
[apt.git] / test / integration / framework
index 2cc6be3dd2669a2ec0f49f4304516df039bf917e..8ea1e1c0d1259e3044d8765f0e543a463c2edfbe 100644 (file)
@@ -477,6 +477,7 @@ configdpkgnoopchroot() {
 #include <stdlib.h>
 #include <string.h>
 #include <dlfcn.h>
 #include <stdlib.h>
 #include <string.h>
 #include <dlfcn.h>
+#include <limits.h>
 
 static char * chrootdir = NULL;
 
 
 static char * chrootdir = NULL;
 
@@ -493,13 +494,11 @@ 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);
        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[strlen(chrootdir) + strlen(file)];
-       strcpy(newfile, chrootdir);
-       strcat(newfile, file);
+       char newfile[PATH_MAX];
+       snprintf(newfile, sizeof(newfile), "%s/%s", chrootdir, file);
        char const * const baseadmindir = "/var/lib/dpkg";
        char const * const baseadmindir = "/var/lib/dpkg";
-       char admindir[strlen(chrootdir) + strlen(baseadmindir)];
-       strcpy(admindir, chrootdir);
-       strcat(admindir, baseadmindir);
+       char admindir[PATH_MAX];
+       snprintf(admindir, sizeof(admindir), "%s/%s", chrootdir, baseadmindir);
        setenv("DPKG_ADMINDIR", admindir, 1);
        return func_execvp(newfile, argv);
 }
        setenv("DPKG_ADMINDIR", admindir, 1);
        return func_execvp(newfile, argv);
 }
@@ -1510,7 +1509,10 @@ msgfailoutput() {
                        if expr match "$1" "$FILEFLAGS" >/dev/null; then
                                echo "#### stat(2) of file: $2 ####"
                                stat "$2" || true
                        if expr match "$1" "$FILEFLAGS" >/dev/null; then
                                echo "#### stat(2) of file: $2 ####"
                                stat "$2" || true
-                               if test -e "$2"; then
+                               if test -d "$2"; then
+                                       echo "#### The directory contains: $2 ####"
+                                       ls >&2 "$2" || true
+                               elif test -e "$2"; then
                                        echo "#### Complete file: $2 ####"
                                        cat >&2 "$2" || true
                                fi
                                        echo "#### Complete file: $2 ####"
                                        cat >&2 "$2" || true
                                fi