Fix incorrect calloc() invocations caught by -Wcalloc-transposed-args
Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
parent
04f02e8cd7
commit
634e808893
41
0002-Fix-reversed-calloc-arguments.patch
Normal file
41
0002-Fix-reversed-calloc-arguments.patch
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
From 1f9e2fa0b4d872fdd01ca3ba81b04dfb1211a187 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Stephen Gallagher <sgallagh@redhat.com>
|
||||||
|
Date: Fri, 2 Feb 2024 09:32:48 -0500
|
||||||
|
Subject: [PATCH] Fix reversed calloc() arguments
|
||||||
|
|
||||||
|
The prototype is "void *calloc(size_t nelem, size_t elsize);"
|
||||||
|
|
||||||
|
These two instances had them reversed, almost certainly leading to
|
||||||
|
buffer overflow issues. This was detected by
|
||||||
|
-Werror=calloc-transposed-args on gcc.
|
||||||
|
|
||||||
|
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
|
||||||
|
---
|
||||||
|
src/pesigcheck.c | 4 ++--
|
||||||
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/pesigcheck.c b/src/pesigcheck.c
|
||||||
|
index 6dc67f76a81..8119cf10a7b 100644
|
||||||
|
--- a/src/pesigcheck.c
|
||||||
|
+++ b/src/pesigcheck.c
|
||||||
|
@@ -240,7 +240,7 @@ check_signature(pesigcheck_context *ctx, int *nreasons,
|
||||||
|
|
||||||
|
cert_iter iter;
|
||||||
|
|
||||||
|
- reasonps = calloc(sizeof(struct reason), 512);
|
||||||
|
+ reasonps = calloc(512, sizeof(struct reason));
|
||||||
|
if (!reasonps)
|
||||||
|
err(1, "check_signature");
|
||||||
|
|
||||||
|
@@ -281,7 +281,7 @@ check_signature(pesigcheck_context *ctx, int *nreasons,
|
||||||
|
|
||||||
|
num_reasons += 16;
|
||||||
|
|
||||||
|
- new_reasons = calloc(sizeof(struct reason), num_reasons);
|
||||||
|
+ new_reasons = calloc(num_reasons, sizeof(struct reason));
|
||||||
|
if (!new_reasons)
|
||||||
|
err(1, "check_signature");
|
||||||
|
reasonps = new_reasons;
|
||||||
|
--
|
||||||
|
2.41.0
|
||||||
|
|
@ -1 +1,2 @@
|
|||||||
Patch0001: 0001-cms_common-Fixed-Segmentation-fault.patch
|
Patch0001: 0001-cms_common-Fixed-Segmentation-fault.patch
|
||||||
|
Patch0002: 0002-Fix-reversed-calloc-arguments.patch
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
Name: pesign
|
Name: pesign
|
||||||
Summary: Signing utility for UEFI binaries
|
Summary: Signing utility for UEFI binaries
|
||||||
Version: 116
|
Version: 116
|
||||||
Release: 2%{?dist}
|
Release: 3%{?dist}
|
||||||
License: GPL-2.0-only
|
License: GPL-2.0-only
|
||||||
URL: https://github.com/rhboot/pesign
|
URL: https://github.com/rhboot/pesign
|
||||||
|
|
||||||
@ -162,6 +162,9 @@ certutil -d %{_sysconfdir}/pki/pesign/ -X -L > /dev/null
|
|||||||
%{python3_sitelib}/mockbuild/plugins/pesign.*
|
%{python3_sitelib}/mockbuild/plugins/pesign.*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Feb 02 2024 Peter Jones <pjones@redhat.com> - 116-3
|
||||||
|
- Fix incorrect calloc() invocations caught by -Wcalloc-transposed-args
|
||||||
|
|
||||||
* Mon Feb 20 2023 Nicolas Frayer <nfrayer@redhat.com> - 116-2
|
* Mon Feb 20 2023 Nicolas Frayer <nfrayer@redhat.com> - 116-2
|
||||||
- cms_common: Fixed Segmentation fault
|
- cms_common: Fixed Segmentation fault
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user