mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-04 08:35:31 +00:00
Merge branch '3930-gcc-12-static-analyzer-warning-dereference-of-null-in-in-siphash-c' into 'main'
Resolve "GCC 12 static analyzer: warning: dereference of NULL 'in' in siphash.c" Closes #3930 See merge request isc-projects/bind9!7656
This commit is contained in:
@@ -90,13 +90,13 @@ isc_siphash24(const uint8_t *k, const uint8_t *in, const size_t inlen,
|
|||||||
|
|
||||||
uint64_t b = ((uint64_t)inlen) << 56;
|
uint64_t b = ((uint64_t)inlen) << 56;
|
||||||
|
|
||||||
const uint8_t *end = (in == NULL)
|
if (in != NULL && inlen != 0) {
|
||||||
? NULL
|
const uint8_t *end = in + inlen - (inlen % sizeof(uint64_t));
|
||||||
: in + inlen - (inlen % sizeof(uint64_t));
|
|
||||||
const size_t left = inlen & 7;
|
const size_t left = inlen & 7;
|
||||||
|
|
||||||
for (; in != end; in += 8) {
|
for (; in != end; in += 8) {
|
||||||
uint64_t m = case_sensitive
|
uint64_t m =
|
||||||
|
case_sensitive
|
||||||
? ISC_U8TO64_LE(in)
|
? ISC_U8TO64_LE(in)
|
||||||
: isc_ascii_tolower8(ISC_U8TO64_LE(in));
|
: isc_ascii_tolower8(ISC_U8TO64_LE(in));
|
||||||
|
|
||||||
@@ -136,6 +136,7 @@ isc_siphash24(const uint8_t *k, const uint8_t *in, const size_t inlen,
|
|||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
v3 ^= b;
|
v3 ^= b;
|
||||||
|
|
||||||
@@ -173,13 +174,13 @@ isc_halfsiphash24(const uint8_t *k, const uint8_t *in, const size_t inlen,
|
|||||||
|
|
||||||
uint32_t b = ((uint32_t)inlen) << 24;
|
uint32_t b = ((uint32_t)inlen) << 24;
|
||||||
|
|
||||||
const uint8_t *end = (in == NULL)
|
if (in != NULL && inlen != 0) {
|
||||||
? NULL
|
const uint8_t *end = in + inlen - (inlen % sizeof(uint32_t));
|
||||||
: in + inlen - (inlen % sizeof(uint32_t));
|
|
||||||
const int left = inlen & 3;
|
const int left = inlen & 3;
|
||||||
|
|
||||||
for (; in != end; in += 4) {
|
for (; in != end; in += 4) {
|
||||||
uint32_t m = case_sensitive
|
uint32_t m =
|
||||||
|
case_sensitive
|
||||||
? ISC_U8TO32_LE(in)
|
? ISC_U8TO32_LE(in)
|
||||||
: isc_ascii_tolower4(ISC_U8TO32_LE(in));
|
: isc_ascii_tolower4(ISC_U8TO32_LE(in));
|
||||||
|
|
||||||
@@ -207,6 +208,7 @@ isc_halfsiphash24(const uint8_t *k, const uint8_t *in, const size_t inlen,
|
|||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
v3 ^= b;
|
v3 ^= b;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user