From: Noel Power Date: Wed, 22 May 2019 10:57:53 +0000 (+0000) Subject: s4/smdb: cppcheck: fix nullPointer: Possible null pointer dereference warning. X-Git-Tag: ldb-2.0.5~509 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c7113a418ce169b486f86238643e2d03112410b;p=thirdparty%2Fsamba.git s4/smdb: cppcheck: fix nullPointer: Possible null pointer dereference warning. Insert unreachable return to satisfy the following warnings source4/smbd/server.c:692: warning: nullPointer: Possible null pointer dereference: state <--[cppcheck] source4/smbd/server.c:694: warning: nullPointer: Possible null pointer dereference: state <--[cppcheck] source4/smbd/server.c:699: warning: nullPointer: Possible null pointer dereference: state <--[cppcheck] source4/smbd/server.c:758: warning: nullPointer: Possible null pointer dereference: state <--[cppcheck] source4/smbd/server.c:789: warning: nullPointer: Possible null pointer dereference: state <--[cppcheck] source4/smbd/server.c:849: warning: nullPointer: Possible null pointer dereference: state <--[cppcheck] source4/smbd/server.c:866: warning: nullPointer: Possible null pointer dereference: state <--[cppcheck] Signed-off-by: Noel Power Reviewed-by: Andreas Schneider --- diff --git a/source4/smbd/server.c b/source4/smbd/server.c index badc21270c0..eb43f28e6b8 100644 --- a/source4/smbd/server.c +++ b/source4/smbd/server.c @@ -381,7 +381,9 @@ static NTSTATUS setup_parent_messaging(struct server_state *state, { struct imessaging_context *msg; NTSTATUS status; - + if (state == NULL) { + return NT_STATUS_UNSUCCESSFUL; + } msg = imessaging_init(state->event_ctx, lp_ctx, cluster_id(getpid(), SAMBA_PARENT_TASKID), @@ -645,6 +647,11 @@ static int binary_smbd_main(const char *binary_name, state = talloc_zero(NULL, struct server_state); if (state == NULL) { exit_daemon("Samba cannot create server state", ENOMEM); + /* + * return is never reached but is here to satisfy static + * checkers + */ + return 1; }; state->binary_name = binary_name; @@ -666,6 +673,11 @@ static int binary_smbd_main(const char *binary_name, TALLOC_FREE(state); exit_daemon("Samba cannot open schannel store " "for secured NETLOGON operations.", EACCES); + /* + * return is never reached but is here to satisfy static + * checkers + */ + return 1; } } @@ -674,6 +686,11 @@ static int binary_smbd_main(const char *binary_name, TALLOC_FREE(state); exit_daemon("Samba failed to disable recusive " "winbindd calls.", EACCES); + /* + * return is never reached but is here to satisfy static + * checkers + */ + return 1; } gensec_init(); /* FIXME: */ @@ -694,6 +711,11 @@ static int binary_smbd_main(const char *binary_name, if (state->event_ctx == NULL) { TALLOC_FREE(state); exit_daemon("Initializing event context failed", EACCES); + /* + * return is never reached but is here to satisfy static + * checkers + */ + return 1; } talloc_set_destructor(state->event_ctx, event_ctx_destructor); @@ -724,6 +746,11 @@ static int binary_smbd_main(const char *binary_name, TALLOC_FREE(state); exit_daemon("Samba failed to set standard input handler", ENOTTY); + /* + * return is never reached but is here to satisfy static + * checkers + */ + return 1; } if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) { @@ -736,6 +763,11 @@ static int binary_smbd_main(const char *binary_name, if (fde == NULL) { TALLOC_FREE(state); exit_daemon("Initializing stdin failed", ENOMEM); + /* + * return is never reached but is here to + * satisfy static checkers + */ + return 1; } } @@ -752,7 +784,12 @@ static int binary_smbd_main(const char *binary_name, if (te == NULL) { TALLOC_FREE(state); exit_daemon("Maxruntime handler failed", ENOMEM); - } + /* + * return is never reached but is here to + * satisfy static checkers + */ + return 1; + } } se = tevent_add_signal(state->event_ctx, @@ -764,6 +801,11 @@ static int binary_smbd_main(const char *binary_name, if (se == NULL) { TALLOC_FREE(state); exit_daemon("Initialize SIGTERM handler failed", ENOMEM); + /* + * return is never reached but is here to satisfy static + * checkers + */ + return 1; } if (lpcfg_server_role(cmdline_lp_ctx) != ROLE_ACTIVE_DIRECTORY_DC @@ -790,12 +832,22 @@ static int binary_smbd_main(const char *binary_name, if (ret != LDB_SUCCESS) { TALLOC_FREE(state); exit_daemon("Samba failed to prime database", EINVAL); + /* + * return is never reached but is here to satisfy static + * checkers + */ + return 1; } if (db_is_backup) { TALLOC_FREE(state); exit_daemon("Database is a backup. Please run samba-tool domain" " backup restore", EINVAL); + /* + * return is never reached but is here to satisfy static + * checkers + */ + return 1; } status = setup_parent_messaging(state, cmdline_lp_ctx); @@ -803,6 +855,11 @@ static int binary_smbd_main(const char *binary_name, TALLOC_FREE(state); exit_daemon("Samba failed to setup parent messaging", NT_STATUS_V(status)); + /* + * return is never reached but is here to satisfy static + * checkers + */ + return 1; } DBG_ERR("%s: using '%s' process model\n", binary_name, model); @@ -817,6 +874,11 @@ static int binary_smbd_main(const char *binary_name, TALLOC_FREE(state); exit_daemon("Samba failed to open process control pipe", errno); + /* + * return is never reached but is here to satisfy static + * checkers + */ + return 1; } smb_set_close_on_exec(child_pipe[0]); smb_set_close_on_exec(child_pipe[1]); @@ -853,6 +915,11 @@ static int binary_smbd_main(const char *binary_name, TALLOC_FREE(state); exit_daemon("Samba failed to start services", NT_STATUS_V(status)); + /* + * return is never reached but is here to + * satisfy static checkers + */ + return 1; } } }