#724 Uninitialized value error in monitor_quit
Closed: Fixed None Opened 13 years ago by sgallagh.

 1167static void monitor_quit(struct tevent_context *ev,
 1168                         struct tevent_signal *se,
 1169                         int signum,
 1170                         int count,
 1171                         void *siginfo,
 1172                         void *private_data)
 1173{
 1174    struct mt_ctx *mt_ctx = talloc_get_type(private_data, struct mt_ctx);
 1175    struct mt_svc *svc;
 1176    pid_t pid;
 1177    int status;
Declaring variable "error" without initializer.
 1178    errno_t error;
 1179    int kret;
 1180    bool killed;
 1181
At conditional (1): "8 <= debug_level" taking the true branch.
At conditional (2): "debug_timestamps" taking the true branch.
 1182    DEBUG(8, ("Received shutdown command\n"));
 1183
At conditional (3): "0 <= debug_level" taking the true branch.
At conditional (4): "debug_timestamps" taking the true branch.
 1184    DEBUG(0, ("Monitor received %s: terminating children\n",
 1185              strsignal(signum)));
 1186
 1187    /* Kill all of our known children manually */
At conditional (5): "svc != NULL" taking the true branch.
 1188    DLIST_FOR_EACH(svc, mt_ctx->svc_list) {
At conditional (6): "svc->pid == 0" taking the false branch.
 1189        if (svc->pid == 0) {
 1190            /* The local provider has no PID */
 1191            continue;
 1192        }
 1193
 1194        killed = false;
At conditional (7): "1 <= debug_level" taking the true branch.
At conditional (8): "debug_timestamps" taking the true branch.
 1195        DEBUG(1, ("Terminating [%s][%d]\n", svc->name, svc->pid));
 1196        do {
 1197            errno = 0;
 1198            kret = kill(svc->pid, SIGTERM);
At conditional (9): "kret < 0" taking the false branch.
 1199            if (kret < 0) {
 1200                error = errno;
 1201                DEBUG(1, ("Couldn't kill [%s][%d]: [%s]\n",
 1202                          svc->name, svc->pid, strerror(error)));
 1203            }
 1204
 1205            do {
 1206                errno = 0;
 1207                pid = waitpid(svc->pid, &status, WNOHANG);
At conditional (10): "pid == -1" taking the false branch.
 1208                if (pid == -1) {
 1209                    /* An error occurred while waiting */
 1210                    error = errno;
 1211                    if (error != EINTR) {
 1212                        DEBUG(0, ("[%d][%s] while waiting for [%s]\n",
 1213                                  error, strerror(error), svc->name));
 1214                        /* Forcibly kill this child */
 1215                        kill(svc->pid, SIGKILL);
 1216                        break;
 1217                    }
At conditional (11): "pid != 0" taking the false branch.
 1218                } else if (pid != 0) {
 1219                    error = 0;
 1220                    if WIFEXITED(status) {
 1221                        DEBUG(1, ("Child [%s] exited gracefully\n", svc->name));
 1222                    } else if WIFSIGNALED(status) {
 1223                        DEBUG(1, ("Child [%s] terminated with a signal\n", svc->name));
 1224                    } else {
 1225                        DEBUG(0, ("Child [%s] did not exit cleanly\n", svc->name));
 1226                        /* Forcibly kill this child */
 1227                        kill(svc->pid, SIGKILL);
 1228                    }
 1229                    killed = true;
 1230                }
Using uninitialized value "error".
 1231            } while (error == EINTR);
 1232            if (!killed) {
 1233                /* Sleep 10ms and try again */
 1234                usleep(10000);
 1235            }
 1236        } while (!killed);
 1237    }

Initialize error to zero


Fields changed

keywords: => Coverity

Fields changed

milestone: NEEDS_TRIAGE => SSSD 1.5.0

Fixed by df60615

coverity: => 10019
resolution: => fixed
status: new => closed

Fields changed

rhbz: => 0

Metadata Update from @sgallagh:
- Issue assigned to sgallagh
- Issue set to the milestone: SSSD 1.5.0

7 years ago

SSSD is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in SSSD's github repository.

This issue has been cloned to Github and is available here:
- https://github.com/SSSD/sssd/issues/1766

If you want to receive further updates on the issue, please navigate to the github issue
and click on subscribe button.

Thank you for understanding. We apologize for all inconvenience.

Login to comment on this ticket.

Metadata