libgcrypt/kdf: Get rid of gpg_err_code_from_errno()

gpg_err_code_from_errno() requires libgcrypt_wrap/mem.c which is not in
Makefile.utilgcry.def. This commit replaces gpg_err_code_from_errno()
with GPG_ERR_* to avoid the build errors.

Signed-off-by: Gary Lin <glin@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Gary Lin 2025-10-15 11:00:19 +08:00 committed by Daniel Kiper
parent 0c06a454fc
commit 1ff7206417
2 changed files with 49 additions and 0 deletions

View File

@ -44,6 +44,7 @@ EXTRA_DIST += grub-core/lib/libgcrypt-patches/06_blake.patch
EXTRA_DIST += grub-core/lib/libgcrypt-patches/07_disable_64div.patch
EXTRA_DIST += grub-core/lib/libgcrypt-patches/08_sexp_leak.patch
EXTRA_DIST += grub-core/lib/libgcrypt-patches/09-blake2b-hash-buffers.patch
EXTRA_DIST += grub-core/lib/libgcrypt-patches/10-kdf-use-GPG-errs.patch
EXTRA_DIST += grub-core/lib/libtasn1-patches/0001-libtasn1-disable-code-not-needed-in-grub.patch
EXTRA_DIST += grub-core/lib/libtasn1-patches/0002-libtasn1-replace-strcat-with-strcpy-in-_asn1_str_cat.patch

View File

@ -0,0 +1,48 @@
From 89f793515d927d8f7099b61d0b7b200611e56acd Mon Sep 17 00:00:00 2001
From: Gary Lin <glin@suse.com>
Date: Mon, 25 Aug 2025 15:56:03 +0800
Subject: [PATCH 2/4] libgcrypt/kdf: Get rid of gpg_err_code_from_errno()
gpg_err_code_from_errno() requires libgcrypt_wrap/mem.c which is not in
Makefile.utilgcry.def. This commit replaces gpg_err_code_from_errno()
with GPG_ERR_* to avoid the build errors.
Signed-off-by: Gary Lin <glin@suse.com>
---
grub-core/lib/libgcrypt-grub/cipher/kdf.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/grub-core/lib/libgcrypt-grub/cipher/kdf.c b/grub-core/lib/libgcrypt-grub/cipher/kdf.c
index 08e3ef658..6e0351d8a 100644
--- a/grub-core/lib/libgcrypt-grub/cipher/kdf.c
+++ b/grub-core/lib/libgcrypt-grub/cipher/kdf.c
@@ -265,7 +265,7 @@ argon2_init (argon2_ctx_t a, unsigned int parallelism,
block = xtrymalloc (1024 * memory_blocks);
if (!block)
{
- ec = gpg_err_code_from_errno (errno);
+ ec = GPG_ERR_OUT_OF_MEMORY;
return ec;
}
memset (block, 0, 1024 * memory_blocks);
@@ -273,7 +273,7 @@ argon2_init (argon2_ctx_t a, unsigned int parallelism,
thread_data = xtrymalloc (a->lanes * sizeof (struct argon2_thread_data));
if (!thread_data)
{
- ec = gpg_err_code_from_errno (errno);
+ ec = GPG_ERR_OUT_OF_MEMORY;
xfree (block);
return ec;
}
@@ -624,7 +624,7 @@ argon2_open (gcry_kdf_hd_t *hd, int subalgo,
n = offsetof (struct argon2_context, out) + taglen;
a = xtrymalloc (n);
if (!a)
- return gpg_err_code_from_errno (errno);
+ return GPG_ERR_OUT_OF_MEMORY;
a->algo = GCRY_KDF_ARGON2;
a->hash_type = hash_type;
--
2.51.0