From: Darren Kenny Date: Thu, 26 Nov 2020 10:41:54 +0000 (+0000) Subject: libgcrypt/mpi: Fix possible NULL dereference X-Git-Tag: grub-2.06-rc1~101 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae0f3fabeba7b393113d5dc185b6aff9b728136d;p=thirdparty%2Fgrub.git libgcrypt/mpi: Fix possible NULL dereference 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 Reviewed-by: Daniel Kiper --- 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