aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-02-25 22:42:36 +0100
committerStefano Brivio <sbrivio@redhat.com>2022-02-25 22:42:36 +0100
commit9b61bd0b392ea1af6717d03e20dcc418ba73f575 (patch)
tree38b3b92ef4df37e3c388869f9b092db3c92d3dfd
parente221ca761394b1431b1ca8c66ae83744dc629006 (diff)
downloadpasst-9b61bd0b392ea1af6717d03e20dcc418ba73f575.tar
passt-9b61bd0b392ea1af6717d03e20dcc418ba73f575.tar.gz
passt-9b61bd0b392ea1af6717d03e20dcc418ba73f575.tar.bz2
passt-9b61bd0b392ea1af6717d03e20dcc418ba73f575.tar.lz
passt-9b61bd0b392ea1af6717d03e20dcc418ba73f575.tar.xz
passt-9b61bd0b392ea1af6717d03e20dcc418ba73f575.tar.zst
passt-9b61bd0b392ea1af6717d03e20dcc418ba73f575.zip
passt: Explicitly check return value of chdir()
...it doesn't actually matter as we're checking errno at the very end, but, depending on build flags, chdir() might be declared with warn_unused_result and the compiler issues a warning. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--passt.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/passt.c b/passt.c
index 3d18d1f..038d50a 100644
--- a/passt.c
+++ b/passt.c
@@ -260,7 +260,9 @@ static int sandbox(struct ctx *c)
mount("", "/", "", MS_UNBINDABLE | MS_REC, NULL);
mount("", TMPDIR, "tmpfs", MS_NODEV | MS_NOEXEC | MS_NOSUID | MS_RDONLY,
"nr_inodes=2,nr_blocks=0");
- chdir(TMPDIR);
+ if (chdir(TMPDIR))
+ return -errno;
+
syscall(SYS_pivot_root, ".", ".");
umount2(".", MNT_DETACH | UMOUNT_NOFOLLOW);