Backport upstream commit to fix a memory leak from a static pointer
This commit is contained in:
parent
d0aedfcdf1
commit
dd0f502c63
@ -0,0 +1,80 @@
|
||||
From 176151db6c456c41be12f7d3a6338559d767cf9b Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= <besser82@fedoraproject.org>
|
||||
Date: Tue, 4 Dec 2018 15:33:04 +0100
|
||||
Subject: [PATCH] Fix memory leak from static pointer in
|
||||
test-crypt-gost-yescrypt.c.
|
||||
|
||||
---
|
||||
test-crypt-gost-yescrypt.c | 29 +++++++++++++++++++----------
|
||||
1 file changed, 19 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/test-crypt-gost-yescrypt.c b/test-crypt-gost-yescrypt.c
|
||||
index c3263d5..39e03e1 100644
|
||||
--- a/test-crypt-gost-yescrypt.c
|
||||
+++ b/test-crypt-gost-yescrypt.c
|
||||
@@ -74,7 +74,7 @@ test_crypt (const char *p, const char *s, const char *m)
|
||||
}
|
||||
|
||||
static int
|
||||
-test_crypt_raw (int m, int p, int s)
|
||||
+test_crypt_raw (int m, int p, int s, char **a, size_t *a_size)
|
||||
{
|
||||
char output[CRYPT_OUTPUT_SIZE];
|
||||
char pass[CRYPT_MAX_PASSPHRASE_SIZE];
|
||||
@@ -101,18 +101,16 @@ test_crypt_raw (int m, int p, int s)
|
||||
return 1;
|
||||
}
|
||||
char *h = strrchr (output, '$') + 1;
|
||||
- static char *a = NULL;
|
||||
- static size_t a_size = 0;
|
||||
- if (a && strstr (a, h))
|
||||
+ if (*a && strstr (*a, h))
|
||||
{
|
||||
fprintf (stderr, "ERROR: duplicated hash %s\n", output);
|
||||
return 1;
|
||||
}
|
||||
size_t len = strlen(h);
|
||||
- a = realloc (a, a_size + len + 1);
|
||||
- strcpy (a + a_size, h);
|
||||
- a_size += len;
|
||||
- a[a_size] = '\0';
|
||||
+ *a = realloc (*a, *a_size + len + 1);
|
||||
+ strcpy (*a + *a_size, h);
|
||||
+ *a_size += len;
|
||||
+ (*a)[*a_size] = '\0';
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -163,12 +161,19 @@ main (void)
|
||||
|
||||
int m, pp, ss;
|
||||
int etest = 0;
|
||||
+ char **a = malloc (sizeof (char*));
|
||||
+ size_t *a_size = malloc (sizeof (size_t));
|
||||
+
|
||||
+ *a = malloc (sizeof (char));
|
||||
+ (*a)[0] = '\0';
|
||||
+ *a_size = 0;
|
||||
+
|
||||
for (m = 1; m < 3; m++)
|
||||
{
|
||||
for (pp = 0; pp < 22; pp++)
|
||||
- etest |= test_crypt_raw (m, pp, 0);
|
||||
+ etest |= test_crypt_raw (m, pp, 0, a, a_size);
|
||||
for (ss = 0; ss < 22; ss++)
|
||||
- etest |= test_crypt_raw (m, pp, ss);
|
||||
+ etest |= test_crypt_raw (m, pp, ss, a, a_size);
|
||||
}
|
||||
fprintf (stderr, "\n");
|
||||
if (etest)
|
||||
@@ -177,6 +182,10 @@ main (void)
|
||||
fprintf (stderr, " ok: entropy test\n");
|
||||
result |= etest;
|
||||
|
||||
+ free (*a);
|
||||
+ free (a);
|
||||
+ free (a_size);
|
||||
+
|
||||
return result;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ fi \
|
||||
|
||||
Name: libxcrypt
|
||||
Version: 4.4.0
|
||||
Release: 3%{?dist}
|
||||
Release: 4%{?dist}
|
||||
Summary: Extended crypt library for DES, MD5, Blowfish and others
|
||||
|
||||
# For explicit license breakdown, see the
|
||||
@ -104,6 +104,7 @@ Patch0001: %{url}/commit/664bfda5a51dbaa75904b29a7cd3c51888db6bd9.patch#/%{
|
||||
Patch0002: %{url}/commit/fdeddd908b6c659b281bbef7e535f9060b5b6186.patch#/%{name}-4.4.0-use_base64_output_gensalt_nt_rn.patch
|
||||
Patch0003: %{url}/commit/f6fe5e6faf4a681984e5bb9d830c8006bba8dab7.patch#/%{name}-4.4.0-set_minimum_rbytes_for_NT_to_2.patch
|
||||
Patch0004: %{url}/commit/580a15e118ee86676ddc1b4456ae6a3f14d86296.patch#/%{name}-4.4.0-test_hmac-sha256_incremental_computation.patch
|
||||
Patch0005: %{url}/commit/176151db6c456c41be12f7d3a6338559d767cf9b.patch#/%{name}-4.4.0-test-crypt-gost-yescrypt_fix_static_pointer_memory_leak.patch
|
||||
|
||||
# Patch 3000 - 5999: Backported patches from pull requests.
|
||||
Patch3000: %{url}/pull/72.patch#/%{name}-4.4.0-buildflags_-fno-plt.patch
|
||||
@ -335,6 +336,9 @@ done
|
||||
|
||||
|
||||
%changelog
|
||||
* Tue Dec 04 2018 Björn Esser <besser82@fedoraproject.org> - 4.4.0-4
|
||||
- Backport upstream commit to fix a memory leak from a static pointer
|
||||
|
||||
* Tue Dec 04 2018 Björn Esser <besser82@fedoraproject.org> - 4.4.0-3
|
||||
- Backport upstream PR to build with -fno-plt optimization
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user