commit:     9bbc0187db3923e17e93801acd2879ef59965548
Author:     Göktürk Yüksek <gokturk <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 19 09:40:12 2018 +0000
Commit:     Göktürk Yüksek <gokturk <AT> gentoo <DOT> org>
CommitDate: Thu Apr 19 09:40:12 2018 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9bbc0187

sys-apps/rng-tools: fix nistbeacon block validation on 32-bit x86

Package-Manager: Portage-2.3.19, Repoman-2.3.6

 ...ools-6.1-fix-nistbeacon-validation-on-x86.patch | 45 ++++++++++++++++++++++
 ...tools-6.1-r1.ebuild => rng-tools-6.1-r2.ebuild} |  3 +-
 2 files changed, 47 insertions(+), 1 deletion(-)

diff --git 
a/sys-apps/rng-tools/files/rng-tools-6.1-fix-nistbeacon-validation-on-x86.patch 
b/sys-apps/rng-tools/files/rng-tools-6.1-fix-nistbeacon-validation-on-x86.patch
new file mode 100644
index 00000000000..1872444bc4a
--- /dev/null
+++ 
b/sys-apps/rng-tools/files/rng-tools-6.1-fix-nistbeacon-validation-on-x86.patch
@@ -0,0 +1,45 @@
+From e8d7ea04e39f1209a79c003f3b62c9f1761dec0e Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?G=C3=B6kt=C3=BCrk=20Y=C3=BCksek?= <gokt...@gentoo.org>
+Date: Thu, 19 Apr 2018 05:29:01 -0400
+Subject: [PATCH] rngd_nistbeacon: fix the size of frequency and timestamp on
+ x86_32
+
+The members "frequency" and "timestamp" of struct nist_data_block are
+defined as int and long, respectively. On x86_64, their sizes
+correctly correspond to 4 and 8 bytes. However, on 32-bit x86
+architectures, both int and long are defined as 4 bytes, causing the
+digest verification to fail. Fix it by using uint32_t and uint64_t
+explicitly.
+---
+ rngd_nistbeacon.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/rngd_nistbeacon.c b/rngd_nistbeacon.c
+index fbebc53..eadde39 100644
+--- a/rngd_nistbeacon.c
++++ b/rngd_nistbeacon.c
+@@ -97,8 +97,8 @@ BIO *bfp;
+ 
+ struct nist_data_block {
+       char *version;
+-      int frequency;
+-      long timestamp;
++      uint32_t frequency;
++      uint64_t timestamp;
+       char *seedvalue;
+       size_t seedvaluelen;
+       char *previoushash;
+@@ -355,8 +355,8 @@ static int validate_nist_block()
+ 
+ 
+       EVP_VerifyUpdate(mdctx, block.version, strlen(block.version));
+-      EVP_VerifyUpdate(mdctx, &block.frequency, sizeof(int));
+-      EVP_VerifyUpdate(mdctx, &block.timestamp, sizeof(long));
++      EVP_VerifyUpdate(mdctx, &block.frequency, sizeof(uint32_t));
++      EVP_VerifyUpdate(mdctx, &block.timestamp, sizeof(uint64_t));
+       EVP_VerifyUpdate(mdctx, block.seedvalue, block.seedvaluelen);
+       EVP_VerifyUpdate(mdctx, block.previoushash, block.previoushashlen);
+       EVP_VerifyUpdate(mdctx, &block.errorcode, block.errorcodelen);
+-- 
+2.13.6
+

diff --git a/sys-apps/rng-tools/rng-tools-6.1-r1.ebuild 
b/sys-apps/rng-tools/rng-tools-6.1-r2.ebuild
similarity index 91%
rename from sys-apps/rng-tools/rng-tools-6.1-r1.ebuild
rename to sys-apps/rng-tools/rng-tools-6.1-r2.ebuild
index 2c149789b75..607a19b11e2 100644
--- a/sys-apps/rng-tools/rng-tools-6.1-r1.ebuild
+++ b/sys-apps/rng-tools/rng-tools-6.1-r2.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2017 Gentoo Foundation
+# Copyright 1999-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=6
@@ -34,6 +34,7 @@ DEPEND="${DEPEND}
 PATCHES=(
        "${FILESDIR}"/test-for-argp.patch
        "${FILESDIR}"/${PN}-5-fix-textrels-on-PIC-x86.patch #469962
+       "${FILESDIR}"/${PN}-6.1-fix-nistbeacon-validation-on-x86.patch
 )
 
 src_prepare() {

Reply via email to