Skip to content
This repository was archived by the owner on Aug 13, 2025. It is now read-only.

Commit 6734b0f

Browse files
committed
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
2 parents a149468 + 349c23d commit 6734b0f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/isc/siphash.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ isc_siphash24(const uint8_t *k, const uint8_t *in, const size_t inlen,
7878
bool case_sensitive, uint8_t *out) {
7979
REQUIRE(k != NULL);
8080
REQUIRE(out != NULL);
81+
REQUIRE(inlen == 0 || in != NULL);
8182

8283
uint64_t k0 = ISC_U8TO64_LE(k);
8384
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,
8990

9091
uint64_t b = ((uint64_t)inlen) << 56;
9192

92-
const uint8_t *end = in + inlen - (inlen % sizeof(uint64_t));
93+
const uint8_t *end = (in == NULL)
94+
? NULL
95+
: in + inlen - (inlen % sizeof(uint64_t));
9396
const size_t left = inlen & 7;
9497

9598
for (; in != end; in += 8) {
@@ -158,6 +161,7 @@ isc_halfsiphash24(const uint8_t *k, const uint8_t *in, const size_t inlen,
158161
bool case_sensitive, uint8_t *out) {
159162
REQUIRE(k != NULL);
160163
REQUIRE(out != NULL);
164+
REQUIRE(inlen == 0 || in != NULL);
161165

162166
uint32_t k0 = ISC_U8TO32_LE(k);
163167
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,
169173

170174
uint32_t b = ((uint32_t)inlen) << 24;
171175

172-
const uint8_t *end = in + inlen - (inlen % sizeof(uint32_t));
176+
const uint8_t *end = (in == NULL)
177+
? NULL
178+
: in + inlen - (inlen % sizeof(uint32_t));
173179
const int left = inlen & 3;
174180

175181
for (; in != end; in += 4) {

0 commit comments

Comments
 (0)