Created
March 9, 2016 15:43
-
-
Save vathpela/64e47faf2199e3a0202e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 7ec93d259d7dfae1d6ba815cb9f9d486c8e79601 Mon Sep 17 00:00:00 2001 | |
From: Peter Jones <[email protected]> | |
Date: Wed, 9 Mar 2016 10:37:43 -0500 | |
Subject: [PATCH] Fix the return code checking in uintn_mult(). | |
We accidentally had the <gcc5 version returning opposite of the >gcc5 | |
version, so on one compiler it worked and the other it failed. | |
Signed-off-by: Peter Jones <[email protected]> | |
--- | |
efi/fwupdate.c | 35 +++++++++++++++++++++-------------- | |
1 file changed, 21 insertions(+), 14 deletions(-) | |
diff --git a/efi/fwupdate.c b/efi/fwupdate.c | |
index 98b9b34..3bafdcf 100644 | |
--- a/efi/fwupdate.c | |
+++ b/efi/fwupdate.c | |
@@ -47,7 +47,7 @@ static int debugging; | |
if ((a) != 0 && (b) != 0) { \ | |
_ret = _limit / (a) < (b); \ | |
} \ | |
- if (_ret) \ | |
+ if (!_ret) \ | |
*(c) = ((a) * (b)); \ | |
_ret; \ | |
}) | |
@@ -99,11 +99,11 @@ read_file(EFI_FILE_HANDLE fh, UINT8 **buf_out, UINTN *buf_size_out) | |
while (1) { | |
void *newb = NULL; | |
UINTN news = 0; | |
- if (!uintn_mult(bs * 2, n_blocks, &news)) { | |
+ if (uintn_mult(bs * 2, n_blocks, &news)) { | |
if (b) | |
free(b, bs * n_blocks); | |
- Print(L"%a:%a():%d: allocation would overflow size\n", | |
- __FILE__, __func__, __LINE__); | |
+ Print(L"%a:%a():%d: allocation %d * %d would overflow size\n", | |
+ __FILE__, __func__, __LINE__, bs * 2, n_blocks); | |
return EFI_OUT_OF_RESOURCES; | |
} | |
rc = allocate(&newb, news); | |
@@ -284,10 +284,11 @@ find_updates(UINTN *n_updates_out, update_table ***updates_out) | |
EFI_GUID vendor_guid = empty_guid; | |
UINTN mult_res; | |
- if (!uintn_mult(sizeof (update_table *), n_updates_allocated, | |
+ if (uintn_mult(sizeof (update_table *), n_updates_allocated, | |
&mult_res)) { | |
- Print(L"%a:%a():%d: would overflow size\n", | |
- __FILE__, __func__, __LINE__); | |
+ Print(L"%a:%a():%d: allocation %d * %d would overflow size\n", | |
+ __FILE__, __func__, __LINE__, | |
+ sizeof (update_table *), n_updates_allocated); | |
return EFI_OUT_OF_RESOURCES; | |
} | |
@@ -323,7 +324,7 @@ find_updates(UINTN *n_updates_out, update_table ***updates_out) | |
CHAR16 *new_name; | |
new_allocation = variable_name_size; | |
- if (!uintn_mult(new_allocation, 2, &mult_res)) { | |
+ if (uintn_mult(new_allocation, 2, &mult_res)) { | |
Print(L"%a:%a():%d: %d * 2 would overflow size\n", | |
__FILE__, __func__, __LINE__, | |
new_allocation); | |
@@ -371,17 +372,23 @@ find_updates(UINTN *n_updates_out, update_table ***updates_out) | |
if (n_updates == n_updates_allocated) { | |
update_table **new_ups; | |
- if (!uintn_mult(n_updates_allocated, 2, &mult_res)) { | |
+ UINTN mul_a, mul_b; | |
+ if (uintn_mult(n_updates_allocated, 2, &mult_res)) { | |
+ mul_a = n_updates_allocated; | |
+ mul_b = 2; | |
mult_err: | |
- Print(L"%a:%a():%d: " | |
- L"allocation would overflow size\n", | |
- __FILE__, __func__, __LINE__); | |
+ Print(L"%a:%a():%d: allocation %d * %d would overflow size\n", | |
+ __FILE__, __func__, __LINE__, | |
+ mul_a, mul_b); | |
ret = EFI_OUT_OF_RESOURCES; | |
goto err; | |
} | |
- if (!uintn_mult(mult_res, sizeof (update_table *), | |
- &mult_res)) | |
+ if (uintn_mult(mult_res, sizeof (update_table *), | |
+ &mult_res)) { | |
+ mul_a = mult_res; | |
+ mul_b = sizeof (update_table *); | |
goto mult_err; | |
+ } | |
new_ups = AllocateZeroPool(mult_res); | |
if (!new_ups) { | |
-- | |
2.5.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment