grub2/0198-disk-AFsplitter-check-argument-validity-before-doing.patch
Peter Jones 8c6b1ac71e Reconcile with upstream once again.
Also include some minor fixes for gcc 5.1.1

Signed-off-by: Peter Jones <pjones@redhat.com>
2015-07-22 09:46:32 -04:00

38 lines
1.1 KiB
Diff

From 7d973359427394a00d1d8778b352b67c9ff486d6 Mon Sep 17 00:00:00 2001
From: Vladimir Serbinenko <phcoder@gmail.com>
Date: Sat, 24 Jan 2015 21:33:30 +0100
Subject: [PATCH 198/506] disk/AFsplitter: check argument validity before doing
any allocs.
This avoids possible memory leaks.
Found by: Coverity scan.
---
grub-core/disk/AFSplitter.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/grub-core/disk/AFSplitter.c b/grub-core/disk/AFSplitter.c
index 7e1bd57..f5a8ddc 100644
--- a/grub-core/disk/AFSplitter.c
+++ b/grub-core/disk/AFSplitter.c
@@ -72,13 +72,13 @@ AF_merge (const gcry_md_spec_t * hash, grub_uint8_t * src, grub_uint8_t * dst,
grub_size_t i;
grub_uint8_t *bufblock;
+ if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN || hash->mdlen == 0)
+ return GPG_ERR_INV_ARG;
+
bufblock = grub_zalloc (blocksize);
if (bufblock == NULL)
return GPG_ERR_OUT_OF_MEMORY;
- if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN || hash->mdlen == 0)
- return GPG_ERR_INV_ARG;
-
grub_memset (bufblock, 0, blocksize);
for (i = 0; i < blocknumbers - 1; i++)
{
--
2.4.3