From 09f9b61bdfa488d78bdba4562eb208bd1f062eaf Mon Sep 17 00:00:00 2001 From: Sam James Date: Tue, 24 Jan 2023 02:45:11 +0000 Subject: install-xattr: fix chdir arg when OLDPWD is nulL Fix core.NonNullParamChecker with chdir(). Clang's scan-build says: ``` install-xattr.c:331:9: warning: Null pointer passed to 1st parameter expecting 'nonnull' [core.NonNullParamChecker] if (chdir(oldpwd) != 0) ^~~~~~~~~~~~~ ``` It's right - oldpwd could easily have been null: ``` $ env -u OLDPWD __PORTAGE_HELPER_PATH=foo ./install-xattr --version ``` Signed-off-by: Sam James --- misc/install-xattr/install-xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/install-xattr/install-xattr.c b/misc/install-xattr/install-xattr.c index 2966af4..33b9fe1 100644 --- a/misc/install-xattr/install-xattr.c +++ b/misc/install-xattr/install-xattr.c @@ -345,7 +345,7 @@ main(int argc, char* argv[]) char *portage_helper_path = getenv("__PORTAGE_HELPER_PATH"); char *portage_helper_canpath = NULL; if (portage_helper_path) - if (chdir(oldpwd) != 0) + if (!oldpwd || chdir(oldpwd) != 0) err(1, "failed to chdir %s", oldpwd); switch (fork()) { -- cgit v1.2.3-65-gdbad