From: Michael Hanselmann Date: Mon, 23 Sep 2019 21:53:55 +0000 (+0000) Subject: regfio: Allow ignoring of checksum X-Git-Tag: talloc-2.3.1~335 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6b6df73b4ce20286b1b7370750d11d0d648d7752;p=thirdparty%2Fsamba.git regfio: Allow ignoring of checksum In order to get good coverage fuzzing code has to either calculate checksums correctly or to disable their verification. This change implements the latter for the "REGF_FILE" structure used by the "regfio_*" family of functions. Signed-off-by: Michael Hanselmann Reviewed-by: Andrew Bartlett Reviewed-by: Uri Simchoni --- diff --git a/source3/registry/regfio.c b/source3/registry/regfio.c index 4c6271cda7a..930ac834d1a 100644 --- a/source3/registry/regfio.c +++ b/source3/registry/regfio.c @@ -482,7 +482,7 @@ static bool read_regf_block( REGF_FILE *file ) prs_mem_free( &ps ); - if ( file->checksum != checksum ) { + if ( file->checksum != checksum && !file->ignore_checksums) { DEBUG(0,("read_regf_block: invalid checksum\n" )); return False; } @@ -1242,6 +1242,7 @@ out: } ZERO_STRUCTP( rb ); rb->fd = -1; + rb->ignore_checksums = false; if ( !(rb->mem_ctx = talloc_init( "regfio_open" )) ) { regfio_close( rb ); diff --git a/source3/registry/regfio.h b/source3/registry/regfio.h index 23a44c9c88a..172427f1985 100644 --- a/source3/registry/regfio.h +++ b/source3/registry/regfio.h @@ -199,6 +199,13 @@ typedef struct { REGF_SK_REC *sec_desc_list; /* list of security descriptors referenced by NK records */ + /* Ignore checksums in input data. Used by fuzzing code to allow more + * coverage without having to calcuate a valid checksum. The checksums + * are merely to detect data corruption and don't provide a security + * value. + */ + bool ignore_checksums; + /* unknowns used to simply writing */ uint32_t unknown1;