Add patch to make unalignment test really unaligned

This commit is contained in:
Björn Esser 2019-05-04 20:29:36 +02:00
parent 8d4af9f9e5
commit f8a50b8a98
No known key found for this signature in database
GPG Key ID: F52E98007594C21D
2 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,47 @@
From 9b2e9bd79cb91f50dd713899544423808f932b09 Mon Sep 17 00:00:00 2001
From: Vitaly Chikunov <vt@altlinux.org>
Date: Sat, 4 May 2019 21:19:06 +0300
Subject: [PATCH] crypt-kat: Make unalignment test really unaligned.
As noted and suggested by Solar.
---
test/crypt-kat.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/test/crypt-kat.c b/test/crypt-kat.c
index 4402e24..19a79b1 100644
--- a/test/crypt-kat.c
+++ b/test/crypt-kat.c
@@ -200,24 +200,27 @@ static void *
calc_hashes_crypt_r_rn (ARG_UNUSED (void *unused))
{
char *hash;
- char pass[CRYPT_MAX_PASSPHRASE_SIZE];
+ union {
+ char pass[CRYPT_MAX_PASSPHRASE_SIZE + 1];
+ int aligned;
+ } u;
size_t i;
struct crypt_data data;
int status = 0;
memset (&data, 0, sizeof data);
- memset (pass, 0, CRYPT_MAX_PASSPHRASE_SIZE);
+ memset (u.pass, 0, CRYPT_MAX_PASSPHRASE_SIZE + 1);
for (i = 0; i < ntests; i++)
{
- strncpy(pass + 1, tests[i].input, CRYPT_MAX_PASSPHRASE_SIZE - 1);
+ strncpy(u.pass + 1, tests[i].input, CRYPT_MAX_PASSPHRASE_SIZE);
printf("[%d]: %s %s\n", strlen(tests[i].input), tests[i].input, tests[i].salt);
errno = 0;
- hash = crypt_r (pass + 1, tests[i].salt, &data);
+ hash = crypt_r (u.pass + 1, tests[i].salt, &data);
status |= report_result ("crypt_r", hash, errno, &tests[i],
ENABLE_FAILURE_TOKENS);
errno = 0;
- hash = crypt_rn (pass + 1, tests[i].salt, &data, (int)sizeof data);
+ hash = crypt_rn (u.pass + 1, tests[i].salt, &data, (int)sizeof data);
status |= report_result ("crypt_rn", hash, errno, &tests[i], false);
}

View File

@ -153,6 +153,7 @@ Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
# Patch 0000 - 2999: Backported patches from upstream.
Patch0000: %{url}/commit/5cce1ebe4e8e303bab593af694c9d30c51cf5eb4.patch#/%{name}-4.4.5-remove_unneeded_union_keyword.patch
Patch0001: %{url}/commit/9b2e9bd79cb91f50dd713899544423808f932b09.patch#/%{name}-4.4.5-make_unalignment_test_really_unaligned.patch
# Patch 3000 - 5999: Backported patches from pull requests.
@ -463,6 +464,7 @@ done
* Sat May 04 2019 Björn Esser <besser82@fedoraproject.org> - 4.4.5-1
- New upstream release (#1706419)
- Add patch to remove an unneeded union keyword
- Add patch to make unalignment test really unaligned
* Fri Mar 15 2019 Björn Esser <besser82@fedoraproject.org> - 4.4.4-2
- Change Recommends: whois-mkpasswd to Fedora 30 and later (#1687870)