CID 442819 442818 442817: Various Coverity Scan issues in qp-trie tests
Coverity Scan claims the following issues in qp-trie tests on main
.
*** CID 442819: Insecure data handling (TAINTED_SCALAR)
/tests/libtest/isc.c: 84 in setup_loopmgr()
78 } else {
79 /* We always need at least two loops for some of the tests */
80 workers = isc_os_ncpus() + 1;
81 }
82 INSIST(workers != 0);
83
>>> CID 442819: Insecure data handling (TAINTED_SCALAR)
>>> Passing tainted expression "workers" to "isc_loopmgr_create", which uses it as an offset.
84 isc_loopmgr_create(mctx, workers, &loopmgr);
85 mainloop = isc_loop_main(loopmgr);
86
87 return (0);
88 }
89
*** CID 442818: Error handling issues (CHECKED_RETURN)
/tests/bench/load-names.c: 130 in new_rbt()
124 * rbt
125 */
126
127 static void *
128 new_rbt(isc_mem_t *mem) {
129 dns_rbt_t *rbt = NULL;
>>> CID 442818: Error handling issues (CHECKED_RETURN)
>>> Calling "dns_rbt_create" without checking return value (as is done elsewhere 15 out of 16 times).
130 dns_rbt_create(mem, NULL, NULL, &rbt);
131 return (rbt);
132 }
133
134 static isc_result_t
135 add_rbt(void *rbt, size_t count) {
*** CID 442817: Memory - illegal accesses (OVERRUN)
/tests/libtest/qp.c: 82 in qp_test_keytoname()
76 /* Scan the key looking for label boundaries */
77 for (offset = 0; offset < 512; offset++) {
78 INSIST(key[offset] >= SHIFT_NOBYTE &&
79 key[offset] < SHIFT_OFFSET);
80 INSIST(loc < 128);
81 if (key[offset] == SHIFT_NOBYTE) {
>>> CID 442817: Memory - illegal accesses (OVERRUN)
>>> Overrunning array of 512 bytes at byte offset 512 by dereferencing pointer "key + (offset + 1UL)".
82 if (key[offset + 1] == SHIFT_NOBYTE) {
83 locs[loc] = offset + 1;
84 break;
85 }
86 locs[loc++] = offset + 1;
87 } else if (offset == 0) {