aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2023-01-24 02:45:11 +0000
committerSam James <sam@gentoo.org>2023-01-24 03:03:23 +0000
commit09f9b61bdfa488d78bdba4562eb208bd1f062eaf (patch)
treee741a6ba4296b6b527747cd7d3ea1e7707b3f431
parentfix-gnustack: pass -Wl,-z,execstack for tests with Clang (diff)
downloadelfix-09f9b61bdfa488d78bdba4562eb208bd1f062eaf.tar.gz
elfix-09f9b61bdfa488d78bdba4562eb208bd1f062eaf.tar.bz2
elfix-09f9b61bdfa488d78bdba4562eb208bd1f062eaf.zip
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 <sam@gentoo.org>
-rw-r--r--misc/install-xattr/install-xattr.c2
1 files changed, 1 insertions, 1 deletions
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()) {