]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ldb_mdb: check fcntl return values (CID 1435851)
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 8 May 2019 00:56:25 +0000 (12:56 +1200)
committerDouglas Bagnall <dbagnall@samba.org>
Thu, 9 May 2019 22:39:27 +0000 (22:39 +0000)
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
lib/ldb/ldb_mdb/ldb_mdb.c

index 68ee97acb644e79cba31ea9daddb5ff3fcf4a80f..9fa10e9e470739d5884386727456d75cb06f8395 100644 (file)
@@ -942,7 +942,16 @@ static int lmdb_open_env(TALLOC_CTX *mem_ctx,
 
        /* Just as for TDB: on exec, don't inherit the fd */
        v = fcntl(fd, F_GETFD, 0);
-       fcntl(fd, F_SETFD, v | FD_CLOEXEC);
+       if (v == -1) {
+               TALLOC_FREE(w);
+               return LDB_ERR_OPERATIONS_ERROR;
+       }
+
+       ret = fcntl(fd, F_SETFD, v | FD_CLOEXEC);
+       if (ret == -1) {
+               TALLOC_FREE(w);
+               return LDB_ERR_OPERATIONS_ERROR;
+       }
 
        if (fstat(fd, &st) != 0) {
                ldb_asprintf_errstring(