HomeClusterLabs Projects

Low: tools/findif: split ValidateNetmaskBits (conv.+valid.)

Description

Low: tools/findif: split ValidateNetmaskBits (conv.+valid.)

This commits moves conversion logic from ValidateNetmaskBits into
a separate function (ConvertNetmaskBitsToInt). This way, we can
validate resulting number of netmask's bits, no matter if the original
string specified netmask as IP expression (via ConvertQuadToInt) or
directly as number of its bits (via ConvertNetmaskBitsToInt).

In turn, we are reaching the original goal to remove ill-advised
reuse of the storage with a string obtained by getenv call
(see netmaskbits, its initialization and rewrite using snprintf).

Strictly viewed, pointer to string returned by getenv should rather
not be stored at all (see [1]), but at least, this patch makes
the program conform to "[t]he application shall ensure that it does
not modify the string pointed to by the getenv() function" part
of getent POSIX documentation (per [1], C standard ditto).

[1] https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=1703960

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>

Details

Provenance
Jan Pokorný <jpokorny@redhat.com>Authored on Oct 4 2012, 7:00 AM
Parents
rRf2fdd408a705: Low: tools/findif: make ConvertQuadToInt use netmask_bits fnc
Branches
Unknown
Tags
Unknown

Event Timeline