mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 22:15:20 +00:00
Merge branch '3787-siphash-c-105-26-runtime-error-applying-zero-offset-to-null-pointer' into 'main'
Resolve "siphash.c:105:26: runtime error: applying zero offset to null pointer" Closes #3787 See merge request isc-projects/bind9!7339
This commit is contained in:
@@ -78,6 +78,7 @@ isc_siphash24(const uint8_t *k, const uint8_t *in, const size_t inlen,
|
|||||||
bool case_sensitive, uint8_t *out) {
|
bool case_sensitive, uint8_t *out) {
|
||||||
REQUIRE(k != NULL);
|
REQUIRE(k != NULL);
|
||||||
REQUIRE(out != NULL);
|
REQUIRE(out != NULL);
|
||||||
|
REQUIRE(inlen == 0 || in != NULL);
|
||||||
|
|
||||||
uint64_t k0 = ISC_U8TO64_LE(k);
|
uint64_t k0 = ISC_U8TO64_LE(k);
|
||||||
uint64_t k1 = ISC_U8TO64_LE(k + 8);
|
uint64_t k1 = ISC_U8TO64_LE(k + 8);
|
||||||
@@ -89,7 +90,9 @@ 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 + inlen - (inlen % sizeof(uint64_t));
|
const uint8_t *end = (in == NULL)
|
||||||
|
? NULL
|
||||||
|
: 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) {
|
||||||
@@ -158,6 +161,7 @@ isc_halfsiphash24(const uint8_t *k, const uint8_t *in, const size_t inlen,
|
|||||||
bool case_sensitive, uint8_t *out) {
|
bool case_sensitive, uint8_t *out) {
|
||||||
REQUIRE(k != NULL);
|
REQUIRE(k != NULL);
|
||||||
REQUIRE(out != NULL);
|
REQUIRE(out != NULL);
|
||||||
|
REQUIRE(inlen == 0 || in != NULL);
|
||||||
|
|
||||||
uint32_t k0 = ISC_U8TO32_LE(k);
|
uint32_t k0 = ISC_U8TO32_LE(k);
|
||||||
uint32_t k1 = ISC_U8TO32_LE(k + 4);
|
uint32_t k1 = ISC_U8TO32_LE(k + 4);
|
||||||
@@ -169,7 +173,9 @@ 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 + inlen - (inlen % sizeof(uint32_t));
|
const uint8_t *end = (in == NULL)
|
||||||
|
? NULL
|
||||||
|
: 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) {
|
||||||
|
Reference in New Issue
Block a user