From 9bfcec29993ce3e53ef0c9456fc9fe951af1d64f Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Mon, 28 Jan 2013 18:28:58 +0100 Subject: [PATCH] lib/linux_ns: check mkdir() return value Fail earlier if we can't create the dirs we need. Reported by Coverity as CID #970969. --- lib/linux_ns.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/linux_ns.c b/lib/linux_ns.c index 2aa8cb82..ca65c445 100644 --- a/lib/linux_ns.c +++ b/lib/linux_ns.c @@ -132,10 +132,16 @@ void linux_namespace_jail() { if (strcmp(uwsgi.ns, "/")) { ns_tmp_mountpoint = uwsgi_concat2(uwsgi.ns, "/.uwsgi_ns_tmp_mountpoint"); - mkdir(ns_tmp_mountpoint, S_IRWXU); + if (mkdir(ns_tmp_mountpoint, S_IRWXU) < 0) { + uwsgi_error("mkdir() ns_tmp_mountpoint"); + exit(1); + } ns_tmp_mountpoint2 = uwsgi_concat2(ns_tmp_mountpoint, "/.uwsgi_ns_tmp_mountpoint"); - mkdir(ns_tmp_mountpoint2, S_IRWXU); + if (mkdir(ns_tmp_mountpoint2, S_IRWXU) < 0) { + uwsgi_error("mkdir() ns_tmp_mountpoint2"); + exit(1); + } if (mount(uwsgi.ns, ns_tmp_mountpoint, "none", MS_BIND, NULL)) { uwsgi_error("mount()");