A number of pf ioctls which copy out arrays have the following
structure:
- Caller specifies the size of the array
- ioctl handler allocates a buffer to store it
- ioctl handler populates the array, returning the actual number of items back to userland
- ioctl handler copies the array to userland
It can happen that the caller specified a size larger than the resulting
array. In this case we were leaving some entries uninitialized but
copying them out anyway. This change modifies the ioctl handlers to
copy out only the number of array entries that we return.
Reported by: KMSAN
Sponsored by: The FreeBSD Foundation