grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SECURITY PATCH 042/117] libgcrypt/mpi: Fix possible NULL dereference


From: Daniel Kiper
Subject: [SECURITY PATCH 042/117] libgcrypt/mpi: Fix possible NULL dereference
Date: Tue, 2 Mar 2021 19:00:49 +0100

From: Darren Kenny <darren.kenny@oracle.com>

The code in gcry_mpi_scan() assumes that buffer is not NULL, but there
is no explicit check for that, so we add one.

Fixes: CID 73757

Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 grub-core/lib/libgcrypt/mpi/mpicoder.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/grub-core/lib/libgcrypt/mpi/mpicoder.c 
b/grub-core/lib/libgcrypt/mpi/mpicoder.c
index 7ecad27b2..6fe389165 100644
--- a/grub-core/lib/libgcrypt/mpi/mpicoder.c
+++ b/grub-core/lib/libgcrypt/mpi/mpicoder.c
@@ -379,6 +379,9 @@ gcry_mpi_scan (struct gcry_mpi **ret_mpi, enum 
gcry_mpi_format format,
   unsigned int len;
   int secure = (buffer && gcry_is_secure (buffer));
 
+  if (!buffer)
+    return gcry_error (GPG_ERR_INV_ARG);
+
   if (format == GCRYMPI_FMT_SSH)
     len = 0;
   else
-- 
2.11.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]