regfio: Allow ignoring of checksum
authorMichael Hanselmann <public@hansmi.ch>
Mon, 23 Sep 2019 21:53:55 +0000 (21:53 +0000)
committerUri Simchoni <uri@samba.org>
Fri, 18 Oct 2019 07:31:45 +0000 (07:31 +0000)
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 <public@hansmi.ch>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>
source3/registry/regfio.c
source3/registry/regfio.h

index 4c6271cda7aa603949f59987086511127199ec67..930ac834d1a2921bab673c6ade1904560a048068 100644 (file)
@@ -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 );
index 23a44c9c88aa9372a749589fd7bf9939ade6ba8e..172427f1985798b529d5191122052b7a5db606b8 100644 (file)
@@ -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;