mirror_zfs/cmd/zstream
Richard Yao d31a7cb4fa
Address theoretical uninitialized variable usage in zstream
Coverity has long complained about the checksum being uninitialized if
an END record is processed before its BEGIN record. This should not
happen, but there was no code to check for it. I had left this unfixed
since it was a low priority issue, but then
9f4ede63d2 added another instance of this.

I am making an effort to "hold the line" to keep new coverity defect
reports from going unaddressed, so I find myself forced to fix this much
earlier than I had originally planned to address it.

The solution is to maintain a counter and a flag. Then use VERIFY
statements to verify the following runtime constraints:

 * Every record either has a corresponding BEGIN record, is a BEGIN
   record or is the end of stream END record for replication streams.
 * BEGIN records cannot be nested. i.e. There must be an END record
   before another BEGIN record may be seen.

Failure to meet these constraints will cause the program to exit.

This is sufficient to ensure that the checksum is never accessed when
uninitialized.

Reported-by: Coverity (CID 1524578)
Reported-by: Coverity (CID 1524633)
Reported-by: Coverity (CID 1527295)
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Damian Szuberski <szuberskidamian@gmail.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14176
2022-12-12 10:40:05 -08:00
..
Makefile.am Add ability to recompress send streams with new compression algorithm 2022-11-10 15:23:46 -08:00
zstream_decompress.c Address theoretical uninitialized variable usage in zstream 2022-12-12 10:40:05 -08:00
zstream_dump.c Fix declarations of non-global variables 2022-10-18 11:05:32 -07:00
zstream_recompress.c Address theoretical uninitialized variable usage in zstream 2022-12-12 10:40:05 -08:00
zstream_redup.c Address theoretical uninitialized variable usage in zstream 2022-12-12 10:40:05 -08:00
zstream_token.c Fix userland dereference NULL return value bugs 2022-09-30 17:02:57 -07:00
zstream.c Add ability to recompress send streams with new compression algorithm 2022-11-10 15:23:46 -08:00
zstream.h Add ability to recompress send streams with new compression algorithm 2022-11-10 15:23:46 -08:00