HomeFreeBSD

MAC/do: Better parsing for IDs (strtoui_strict())

Description

MAC/do: Better parsing for IDs (strtoui_strict())

Introduce strtoui_strict(), which signals an error on overflow contrary
to the in-kernel strto*() family of functions which have no 'errno' to
set and thus do not allow callers to distinguish a genuine maximum value
on input and overflow.

It is built on top of strtoq() and the 'quad_t' type in order to achieve
this distinction and also to still support negative inputs with the
usual meaning for these functions. See the introduced comments for more
details.

Use strtoui_strict() to read IDs instead of strtol().

Reviewed by: bapt
Approved by: markj (mentor)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D47614

Details

Provenance
olceAuthored on Jul 5 2024, 12:16 PM
Reviewer
bapt
Differential Revision
D47614: MAC/do: Better parsing for IDs (strtoui_strict())
Parents
rG6aadc7b2ee05: MAC/do: 'struct rule': IDs and types as 'u_int', rename fields
Branches
Unknown
Tags
Unknown