From bfcfae72a57103d5bfae4b54b7ea10602bab838e Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Wed, 8 May 2019 12:56:25 +1200 Subject: [PATCH] ldb_mdb: check fcntl return values (CID 1435851) Signed-off-by: Douglas Bagnall Reviewed-by: Gary Lockyer --- lib/ldb/ldb_mdb/ldb_mdb.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/ldb/ldb_mdb/ldb_mdb.c b/lib/ldb/ldb_mdb/ldb_mdb.c index 68ee97acb64..9fa10e9e470 100644 --- a/lib/ldb/ldb_mdb/ldb_mdb.c +++ b/lib/ldb/ldb_mdb/ldb_mdb.c @@ -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( -- 2.47.3