s4: server: Add error return checks for tevent_add_fde, tevent_add_timer.
authorJeremy Allison <jra@samba.org>
Fri, 31 Mar 2017 19:29:03 +0000 (12:29 -0700)
committerJeremy Allison <jra@samba.org>
Mon, 17 Apr 2017 17:13:07 +0000 (19:13 +0200)
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source4/smbd/server.c

index d80a94db78576d7255f1f5bba95e49ea579f60a2..1e5d57940cec7451c7856405f90621c9157e78e2 100644 (file)
@@ -497,23 +497,30 @@ static int binary_smbd_main(const char *binary_name,
        }
 
        if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) {
-               tevent_add_fd(state->event_ctx,
+               struct tevent_fd *fde = tevent_add_fd(state->event_ctx,
                                state->event_ctx,
                                0,
                                stdin_event_flags,
                                server_stdin_handler,
                                state);
+               if (fde == NULL) {
+                       exit_daemon("Initializing stdin failed", ENOMEM);
+               }
        }
 
        if (max_runtime) {
+               struct tevent_timer *te;
                DEBUG(0,("%s PID %d was called with maxruntime %d - "
                        "current ts %llu\n",
                        binary_name, (int)getpid(),
                        max_runtime, (unsigned long long) time(NULL)));
-               tevent_add_timer(state->event_ctx, state->event_ctx,
+               te = tevent_add_timer(state->event_ctx, state->event_ctx,
                                 timeval_current_ofs(max_runtime, 0),
                                 max_runtime_handler,
                                 state);
+               if (te == NULL) {
+                       exit_daemon("Maxruntime handler failed", ENOMEM);
+               }
        }
 
        if (lpcfg_server_role(cmdline_lp_ctx) != ROLE_ACTIVE_DIRECTORY_DC