kdc: start_kdc avoid warning
The prior structure of the code was safe but can appear otherwise to static analyzers since the assignment to pids[i] occurs after exitting the for() loop. While here use calloc() instead of malloc()/memset(). Change-Id: I8455aa259fd8c7c17778827937ec26127fe0785c
This commit is contained in:
@@ -1116,10 +1116,9 @@ start_kdc(krb5_context context,
|
|||||||
if (max_kdcs < 1)
|
if (max_kdcs < 1)
|
||||||
max_kdcs = 1;
|
max_kdcs = 1;
|
||||||
|
|
||||||
pids = malloc(max_kdcs * sizeof(*pids));
|
pids = calloc(max_kdcs, sizeof(*pids));
|
||||||
if (!pids)
|
if (!pids)
|
||||||
krb5_err(context, 1, errno, "malloc");
|
krb5_err(context, 1, errno, "malloc");
|
||||||
memset(pids, 0x0, max_kdcs * sizeof(*pids));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We open a socketpair of which we hand one end to each of our kids.
|
* We open a socketpair of which we hand one end to each of our kids.
|
||||||
@@ -1190,10 +1189,12 @@ start_kdc(krb5_context context,
|
|||||||
sleep(10);
|
sleep(10);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
for (i=0; i < max_kdcs; i++)
|
for (i=0; i < max_kdcs; i++) {
|
||||||
if (pids[i] == 0)
|
if (pids[i] == 0) {
|
||||||
|
pids[i] = pid;
|
||||||
break;
|
break;
|
||||||
pids[i] = pid;
|
}
|
||||||
|
}
|
||||||
kdc_log(context, config, 0, "KDC worker process started: %d", pid);
|
kdc_log(context, config, 0, "KDC worker process started: %d", pid);
|
||||||
num_kdcs++;
|
num_kdcs++;
|
||||||
gettimeofday(&tv1, NULL);
|
gettimeofday(&tv1, NULL);
|
||||||
|
Reference in New Issue
Block a user