HomeFreeBSD

MFC further inetd(8) cleanup: r356204, r356215, r356217-r356218,

Description

MFC further inetd(8) cleanup: r356204, r356215, r356217-r356218,
r356246-r356248, r356254, r356318

r356204:
inetd: don't leak policy on return

sep->se_policy gets a strdup'd version of policy, so we don't need it to
stick around afterwards.

While here, remove a couple of NULL checks prior to free(policy).

r356215:
inetd: knock out some clang analyze warnings

chargen_dg: clang-analyze is convinced that endring could be non-NULL at
entry, and thus wants to assume that rs == NULL. Just independently
initialize rs if it's NULL to appease the analyzer.

getconfigent: policy leaks on return

free_connlist: reorganize the loop to make it clear that we're not going to
access conn after it's been freed.

cpmip/hashval: left-shifts performed will result in UB as we take
signed 0xABC3D20F and left shift it by 5.

r356217:
inetd: prefer strtonum(3) to strspn(3)+atoi(3), NFC

strtonum(3) does effectively the same validation as we had, but it's more
concise.

r356218:
inetd: prefer strlcpy to strlen(3) check + strcpy(3), NFC

This is again functionally equivalent but more concise.

r356246:
inetd: add some macros for checking child limits, NFC

The main point here is capturing the maxchild > 0 check. A future change to
inetd will start tracking all of the child pids so that it can give proper
and consistent notification of process exit/signalling.

r356247:
inetd: track all child pids, regardless of maxchild spec

Currently, child pids are only tracked if maxchildren is specified. As a
consequence, without a maxchild limit we do not get a notice in syslog on
children aborting abnormally. This turns out to be a great debugging aide at
times.

Children are now tracked in a LIST; the management interface is decidedly
less painful when there's no upper bound on the number of entries we may
have at the cost of one small allocation per connection.

r356248:
inetd: convert remaining bzero(3) to memset(3), NFC

This change is purely in the name of noise reduction from static analyzers
that want to complain that bzero(3) is obsolete in favor of memset(3).

With this, clang-analyze at least is now noise free. WARNS= 6 also appears
to have been OK for some time now, so drop the current setting and opt for
the default.

r356254:
inetd: final round of trivial cleanup, NFC

Highlights:

  • Use MAX() for maxsock raising; small readability improvement IMO
  • malloc(3) + memset(3) -> calloc(3) where appropriate
  • stop casting the return value of malloc(3)
  • mallloc(3) -> reallocarray(3) where appropriate

A future change may enter capability mode when forking for some of the
built-in handlers.

r356318:
inetd: fix WITHOUT_TCP_WRAPPERS build after r356248

After increasing WARNS, building WITHOUT_TCP_WRAPPERS failed because of
some unused variables.

Details

Provenance
kevansAuthored on
Parents
rS356387: MFC r310921, r311354, r315644: Light inetd(8) cleanup
Branches
Unknown
Tags
Unknown