HomeFreeBSD

nvpair: Use flexible array member for nvpair name strings

Description

nvpair: Use flexible array member for nvpair name strings

Coverity reported possible out-of-bounds reads from doing `((char
*)(nvp) + sizeof (nvpair_t))` to get the nvpair name string. These were
initially marked as false positives, but since we are now using C99
flexible array members elsewhere, we could use them here too as cleanup
to make the code easier to understand.

Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reported-by: Coverity (CID-977165)
Reported-by: Coverity (CID-1524109)
Reported-by: Coverity (CID-1524642)
Closes #14612

Details

Provenance
Richard Yao <richard.yao@alumni.stonybrook.edu>Authored on Mar 11 2023, 6:39 PM
Brian Behlendorf <behlendorf1@llnl.gov>Committed on Mar 14 2023, 10:25 PM
Parents
rGd1807f168edd: nvpair: Constify string functions
Branches
Unknown
Tags
Unknown

Event Timeline

Brian Behlendorf <behlendorf1@llnl.gov> committed rGdbfc622345f9: nvpair: Use flexible array member for nvpair name strings (authored by Richard Yao <richard.yao@alumni.stonybrook.edu>).Mar 14 2023, 10:25 PM