diff options
Diffstat (limited to 'dpkg-deb/extract.c')
-rw-r--r-- | dpkg-deb/extract.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/dpkg-deb/extract.c b/dpkg-deb/extract.c index ddb8709cd..605a18440 100644 --- a/dpkg-deb/extract.c +++ b/dpkg-deb/extract.c @@ -137,10 +137,11 @@ extracthalf(const char *debar, const char *dir, if (r != sizeof(arh)) read_fail(r, debar, _("archive member header")); - dpkg_ar_normalize_name(&arh); - if (dpkg_ar_member_is_illegal(&arh)) ohshit(_("file '%.250s' is corrupt - bad archive header magic"), debar); + + dpkg_ar_normalize_name(&arh); + memberlen = dpkg_ar_member_get_size(ar, &arh); if (!header_done) { char *infobuf; @@ -302,9 +303,10 @@ extracthalf(const char *debar, const char *dir, } close(p1[0]); dpkg_ar_close(ar); - if (taroption) close(p2[1]); if (taroption) { + close(p2[1]); + c3 = subproc_fork(); if (!c3) { struct command cmd; @@ -336,15 +338,15 @@ extracthalf(const char *debar, const char *dir, unsetenv("TAR_OPTIONS"); if (dir) { - if (chdir(dir)) { - if (errno != ENOENT) - ohshite(_("failed to chdir to directory")); - - if (mkdir(dir, 0777)) + if (mkdir(dir, 0777) != 0) { + if (errno != EEXIST) ohshite(_("failed to create directory")); - if (chdir(dir)) - ohshite(_("failed to chdir to directory after creating it")); + + if (taroption & DPKG_TAR_CREATE_DIR) + ohshite(_("unexpected pre-existing pathname %s"), dir); } + if (chdir(dir) != 0) + ohshite(_("failed to chdir to directory")); } command_exec(&cmd); @@ -490,7 +492,7 @@ do_raw_extract(const char *const *argv) data_options |= DPKG_TAR_LIST; extracthalf(debar, dir, data_options, 0); - extracthalf(debar, control_dir, DPKG_TAR_EXTRACT, 1); + extracthalf(debar, control_dir, DPKG_TAR_EXTRACT | DPKG_TAR_CREATE_DIR, 1); free(control_dir); |