From 3e114bcb1eb3a2e3c79e7ee7fdc3eeb66a87d711 Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Fri, 21 Feb 2025 14:55:19 +0100 Subject: [PATCH] Fix warning about NULL argument in setsockopt() This should fix a warning produced by scan-build-20 warning: The 4th argument to 'setsockopt' is NULL but should not be NULL [unix.StdCLibraryFunctions] --- lib/crypto_backend/crypto_cipher_kernel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/crypto_backend/crypto_cipher_kernel.c b/lib/crypto_backend/crypto_cipher_kernel.c index 9960cd13..e4ab924a 100644 --- a/lib/crypto_backend/crypto_cipher_kernel.c +++ b/lib/crypto_backend/crypto_cipher_kernel.c @@ -40,6 +40,8 @@ static int _crypt_cipher_init(struct crypt_cipher_kernel *ctx, const void *key, size_t key_length, size_t tag_length, struct sockaddr_alg *sa) { + void *optval = NULL; + if (!ctx) return -EINVAL; @@ -60,7 +62,7 @@ static int _crypt_cipher_init(struct crypt_cipher_kernel *ctx, return -EINVAL; } - if (tag_length && setsockopt(ctx->tfmfd, SOL_ALG, ALG_SET_AEAD_AUTHSIZE, NULL, tag_length) < 0) { + if (tag_length && setsockopt(ctx->tfmfd, SOL_ALG, ALG_SET_AEAD_AUTHSIZE, &optval, tag_length) < 0) { crypt_cipher_destroy_kernel(ctx); return -EINVAL; }