From e0426187eb3b5ef319c4ac8c5cf7442abbc0b0b5 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 2 Mar 2021 11:30:44 +0100 Subject: [PATCH] dsdb: Fix CID 1473454: Null pointer dereferences Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- source4/dsdb/samdb/ldb_modules/rootdse.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source4/dsdb/samdb/ldb_modules/rootdse.c b/source4/dsdb/samdb/ldb_modules/rootdse.c index 9fe49772106..865a43256d8 100644 --- a/source4/dsdb/samdb/ldb_modules/rootdse.c +++ b/source4/dsdb/samdb/ldb_modules/rootdse.c @@ -313,8 +313,14 @@ static int rootdse_add_dynamic(struct rootdse_context *ac, struct ldb_message *m } if (do_attribute(attrs, "currentTime")) { - if (ldb_msg_add_steal_string(msg, "currentTime", - ldb_timestring(msg, time(NULL))) != LDB_SUCCESS) { + char *timestr = ldb_timestring(msg, time(NULL)); + + if (timestr == NULL) { + goto failed; + } + + if (ldb_msg_add_steal_string( + msg, "currentTime", timestr) != LDB_SUCCESS) { goto failed; } }