8000 dereference before NULL check · g-coder/nettle@60aa4d0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 60aa4d0

Browse files
committed
dereference before NULL check
In tools/output.c Pointer 'output->hash' which was dereferenced at #302 is compared to NULL value at #304. If output->hash is NULL then derefrencing it tries to read data from invalid location. Running program with NULL pointer will crash the system. Solution: Check output->hash for NULL value before dereferencing it. place assert(output->hash); before TEMP_ALLOC at #302.
1 parent 27e03db commit 60aa4d0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tools/output.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,11 @@ void
290290
sexp_put_digest(struct sexp_output *output)
291291
{
292292
TMP_DECL(digest, uint8_t, NETTLE_MAX_HASH_DIGEST_SIZE);
293-
TMP_ALLOC(digest, output->hash->digest_size);
294293

295294
assert(output->hash);
296-
295+
296+
TMP_ALLOC(digest, output->hash->digest_size);
297+
297298
output->hash->digest(output->ctx, output->hash->digest_size, digest);
298299

299300
sexp_put_code_start(output, &nettle_base16);

0 commit comments

Comments
 (0)
0