]> git.ipfire.org Git - thirdparty/bind9.git/commit
Silence Untrusted value as argument (TAINTED_SCALAR)
authorMark Andrews <marka@isc.org>
Wed, 27 Jan 2021 06:11:52 +0000 (17:11 +1100)
committerMark Andrews <marka@isc.org>
Thu, 11 Feb 2021 23:43:19 +0000 (10:43 +1100)
commit8302e9fb69d6c9d9606652ff8604eceefb305ec5
tree3eac424f12dec48544011117622845644521f485
parentd52e67211a185da76e79a48a546d1409b5f6e396
Silence Untrusted value as argument (TAINTED_SCALAR)

Coverity assumes that the memory holding any value read using byte
swapping is tainted.  As we store the NSEC3 records in wire form
and iterations is byte swapped the memory holding the record is
marked as tainted.  nsec3->salt_length and nsec3->next_length are
marked as tainted transitively. To remove the taint the values need
to be range checked.  Valid values for these should never exceed
region.length so that is becomes a reasonable value to check against.

    *** CID 316509:    (TAINTED_SCALAR)
    /lib/dns/rdata/generic/nsec3_50.c: 312 in tostruct_nsec3()
    306      if (nsec3->salt == NULL) {
    307      return (ISC_R_NOMEMORY);
    308      }
    309      isc_region_consume(&region, nsec3->salt_length);
    310
    311      nsec3->next_length = uint8_consume_fromregion(&region);
    >>>     CID 316509:    (TAINTED_SCALAR)
    >>>     Passing tainted expression "nsec3->next_length" to "mem_maybedup", which uses it as an offset.
    312      nsec3->next = mem_maybedup(mctx, region.base, nsec3->next_length);
    313      if (nsec3->next == NULL) {
    314      goto cleanup;
    315      }
    316      isc_region_consume(&region, nsec3->next_length);
    317
    /lib/dns/rdata/generic/nsec3_50.c: 305 in tostruct_nsec3()
    299      region.length = rdata->length;
    300      nsec3->hash = uint8_consume_fromregion(&region);
    301      nsec3->flags = uint8_consume_fromregion(&region);
    302      nsec3->iterations = uint16_consume_fromregion(&region);
    303
    304      nsec3->salt_length = uint8_consume_fromregion(&region);
    >>>     CID 316509:    (TAINTED_SCALAR)
    >>>     Passing tainted expression "nsec3->salt_length" to "mem_maybedup", which uses it as an offset.
    305      nsec3->salt = mem_maybedup(mctx, region.base, nsec3->salt_length);
    306      if (nsec3->salt == NULL) {
    307      return (ISC_R_NOMEMORY);
    308      }
    309      isc_region_consume(&region, nsec3->salt_length);
    310

(cherry picked from commit fd8d1337a53a68c5e3145dadec173674f2db0cfb)
lib/dns/rdata/generic/nsec3_50.c