[Reproducible-commits] [dpkg] 39/74: dpkg: Cleanup instdir handling in maintscript_pre_exec()
Mattia Rizzolo
mattia at debian.org
Sun Jul 3 22:22:55 UTC 2016
This is an automated email from the git hooks/post-receive script.
mattia pushed a commit to annotated tag 1.18.8
in repository dpkg.
commit 87ee98484404dfca3e3b59622def0b953e9bdd7f
Author: Guillem Jover <guillem at debian.org>
Date: Sat May 14 19:40:37 2016 +0200
dpkg: Cleanup instdir handling in maintscript_pre_exec()
Rename instdirl to instdirlen. Use that instead of checking if the first
character of instdir is non-NUL. Move the changedir assignment to a
proper if/else conditional.
---
src/script.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/src/script.c b/src/script.c
index 12e5555..14a75ea 100644
--- a/src/script.c
+++ b/src/script.c
@@ -98,13 +98,18 @@ static const char *
maintscript_pre_exec(struct command *cmd)
{
const char *admindir = dpkg_db_get_dir();
- const char *changedir = (*instdir && fc_script_chrootless) ? instdir : "/";
- size_t instdirl = strlen(instdir);
+ const char *changedir;
+ size_t instdirlen = strlen(instdir);
- if (*instdir && !fc_script_chrootless) {
- if (strncmp(admindir, instdir, instdirl) != 0)
+ if (instdirlen > 0 && fc_script_chrootless)
+ changedir = instdir;
+ else
+ changedir = "/";
+
+ if (instdirlen > 0 && !fc_script_chrootless) {
+ if (strncmp(admindir, instdir, instdirlen) != 0)
ohshit(_("admindir must be inside instdir for dpkg to work properly"));
- if (setenv("DPKG_ADMINDIR", admindir + instdirl, 1) < 0)
+ if (setenv("DPKG_ADMINDIR", admindir + instdirlen, 1) < 0)
ohshite(_("unable to setenv for subprocesses"));
if (setenv("DPKG_ROOT", "", 1) < 0)
ohshite(_("unable to setenv for subprocesses"));
@@ -129,11 +134,11 @@ maintscript_pre_exec(struct command *cmd)
args.buf);
varbuf_destroy(&args);
}
- if (!instdirl || fc_script_chrootless)
+ if (instdirlen == 0 || fc_script_chrootless)
return cmd->filename;
- assert(strlen(cmd->filename) >= instdirl);
- return cmd->filename + instdirl;
+ assert(strlen(cmd->filename) >= instdirlen);
+ return cmd->filename + instdirlen;
}
/**
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git
More information about the Reproducible-commits
mailing list