Fix usage of pointer after realloc
This commit is contained in:
parent
52e7f7c1c4
commit
fb3eef40eb
30
opensc-0.22.0-realloc-pointer.patch
Normal file
30
opensc-0.22.0-realloc-pointer.patch
Normal file
@ -0,0 +1,30 @@
|
||||
From b3537ced353579b59e2421645707e9aeda64ff29 Mon Sep 17 00:00:00 2001
|
||||
From: Veronika Hanulikova <vhanulik@redhat.com>
|
||||
Date: Wed, 16 Feb 2022 11:59:27 +0100
|
||||
Subject: [PATCH] Fix usage of pointer after realloc
|
||||
|
||||
---
|
||||
src/sm/sm-iso.c | 5 +++--
|
||||
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/sm/sm-iso.c b/src/sm/sm-iso.c
|
||||
index 5baded77c6..2c3f6bcabd 100644
|
||||
--- a/src/sm/sm-iso.c
|
||||
+++ b/src/sm/sm-iso.c
|
||||
@@ -181,13 +181,14 @@ static int format_le(size_t le, struct sc_asn1_entry *le_entry,
|
||||
|
||||
static int prefix_buf(u8 prefix, u8 *buf, size_t buflen, u8 **cat)
|
||||
{
|
||||
- u8 *p;
|
||||
+ u8 *p = NULL;
|
||||
+ int ptr_same = *cat == buf;
|
||||
|
||||
p = realloc(*cat, buflen + 1);
|
||||
if (!p)
|
||||
return SC_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
- if (*cat == buf) {
|
||||
+ if (ptr_same) {
|
||||
memmove(p + 1, p, buflen);
|
||||
} else {
|
||||
/* Flawfinder: ignore */
|
@ -18,6 +18,8 @@ Patch6: %{name}-32b-arch.patch
|
||||
Patch8: %{name}-%{version}-file-cache.patch
|
||||
# https://github.com/OpenSC/OpenSC/pull/2414 (#2007029)
|
||||
Patch9: %{name}-%{version}-detect-empty.patch
|
||||
# https://github.com/OpenSC/OpenSC/pull/2512 (#2046792)
|
||||
Patch10: %{name}-%{version}-realloc-pointer.patch
|
||||
|
||||
BuildRequires: make
|
||||
BuildRequires: pcsc-lite-devel
|
||||
@ -59,6 +61,7 @@ every software/card that does so, too.
|
||||
%patch6 -p1 -b .32b
|
||||
%patch8 -p1 -b .file-cache
|
||||
%patch9 -p1 -b .detect-empty
|
||||
%patch10 -p1 -b .realloc-pointer
|
||||
|
||||
# The test-pkcs11-tool-allowed-mechanisms already works in Fedora
|
||||
sed -i -e '/XFAIL_TESTS/,$ {
|
||||
|
Loading…
Reference in New Issue
Block a user