Gentoo Archives: gentoo-commits

From: Kent Fredric <kentnl@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-perl/Crypt-CipherSaber/, dev-perl/Crypt-CipherSaber/files/
Date: Mon, 02 Oct 2017 17:26:41
Message-Id: 1506965183.1c357ffc431fa160203f77fa4ef3bb524cc26114.kentnl@gentoo
1 commit: 1c357ffc431fa160203f77fa4ef3bb524cc26114
2 Author: Kent Fredric <kentnl <AT> gentoo <DOT> org>
3 AuthorDate: Mon Oct 2 17:25:49 2017 +0000
4 Commit: Kent Fredric <kentnl <AT> gentoo <DOT> org>
5 CommitDate: Mon Oct 2 17:26:23 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1c357ffc
7
8 dev-perl/Crypt-CipherSaber: Fix handling of newlines in IVs bug #632253
9
10 Closes: https://bugs.gentoo.org/632253
11 Package-Manager: Portage-2.3.8, Repoman-2.3.3
12
13 .../Crypt-CipherSaber-1.10.0-r1.ebuild | 28 +++++
14 .../Crypt-CipherSaber-1.10.0-newline-iv.patch | 118 +++++++++++++++++++++
15 2 files changed, 146 insertions(+)
16
17 diff --git a/dev-perl/Crypt-CipherSaber/Crypt-CipherSaber-1.10.0-r1.ebuild b/dev-perl/Crypt-CipherSaber/Crypt-CipherSaber-1.10.0-r1.ebuild
18 new file mode 100644
19 index 00000000000..090eff20d1b
20 --- /dev/null
21 +++ b/dev-perl/Crypt-CipherSaber/Crypt-CipherSaber-1.10.0-r1.ebuild
22 @@ -0,0 +1,28 @@
23 +# Copyright 1999-2017 Gentoo Foundation
24 +# Distributed under the terms of the GNU General Public License v2
25 +
26 +EAPI=6
27 +
28 +DIST_AUTHOR=CHROMATIC
29 +DIST_VERSION=1.01
30 +inherit perl-module
31 +
32 +DESCRIPTION="Perl module implementing CipherSaber encryption"
33 +
34 +SLOT="0"
35 +KEYWORDS="~amd64 ~x86"
36 +IUSE="test"
37 +
38 +RDEPEND="
39 + >=virtual/perl-Scalar-List-Utils-1.4.2
40 +"
41 +DEPEND="${RDEPEND}
42 + dev-perl/Module-Build
43 + test? (
44 + >=virtual/perl-Test-Simple-0.600.0
45 + >=dev-perl/Test-Warn-0.300.0
46 + )
47 +"
48 +PATCHES=(
49 + "${FILESDIR}/${P}-newline-iv.patch"
50 +)
51
52 diff --git a/dev-perl/Crypt-CipherSaber/files/Crypt-CipherSaber-1.10.0-newline-iv.patch b/dev-perl/Crypt-CipherSaber/files/Crypt-CipherSaber-1.10.0-newline-iv.patch
53 new file mode 100644
54 index 00000000000..30e7a1a1ea4
55 --- /dev/null
56 +++ b/dev-perl/Crypt-CipherSaber/files/Crypt-CipherSaber-1.10.0-newline-iv.patch
57 @@ -0,0 +1,118 @@
58 +From 966c275a76fa33b57f41cb66a908362b526629a8 Mon Sep 17 00:00:00 2001
59 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@××××××.com>
60 +Date: Wed, 27 Aug 2014 15:38:54 +0200
61 +Subject: Fix reading IV with new-lines from a file
62 +MIME-Version: 1.0
63 +Content-Type: text/plain; charset=UTF-8
64 +Content-Transfer-Encoding: 8bit
65 +
66 +Decrypting filehandle data by fh_crypt() could produce bad decrypted
67 +data if the initizalization vector read from the filehandle contained
68 +a new-line character. This caused random failures of 'autogenerating
69 +and autoreading IV should also round-trip' test in t/fh_encrypt.t.
70 +
71 +This patch fixes it by reading first 10 characters regardless of
72 +current line separator.
73 +
74 +Bug: https://rt.cpan.org/Ticket/Display.html?id=28370
75 +Bug: https://bugs.gentoo.org/632253
76 +
77 +Signed-off-by: Petr Písař <ppisar@××××××.com>
78 +---
79 + lib/Crypt/CipherSaber.pm | 14 +++++++++-----
80 + t/fh_encrypt.t | 40 +++++++++++++++++++++++++++++++++++++++-
81 + 2 files changed, 48 insertions(+), 6 deletions(-)
82 +
83 +diff --git a/lib/Crypt/CipherSaber.pm b/lib/Crypt/CipherSaber.pm
84 +index 7cb7cc0..2db153c 100644
85 +--- a/lib/Crypt/CipherSaber.pm
86 ++++ b/lib/Crypt/CipherSaber.pm
87 +@@ -67,6 +67,15 @@ sub fh_crypt
88 + $iv = $self->_gen_iv() if length($iv) == 1;
89 + $self->_setup_key($iv);
90 + print OUT $iv;
91 ++ } else {
92 ++ if ( 10 != $in->read($iv, 10) )
93 ++ {
94 ++ require Carp;
95 ++ Carp::carp( 'Could not read IV from input filehandle' );
96 ++ return;
97 ++ }
98 ++ ( $iv ) = unpack( "a10", $iv );
99 ++ $self->_setup_key($iv);
100 + }
101 +
102 + my $state = $self->[1];
103 +@@ -75,11 +84,6 @@ sub fh_crypt
104 +
105 + while (<$in>)
106 + {
107 +- unless ($iv)
108 +- {
109 +- ( $iv, $_ ) = unpack( "a10a*", $_ );
110 +- $self->_setup_key($iv);
111 +- }
112 + my $line;
113 + ( $line, $state, @vars ) = _do_crypt( $state, $_, @vars );
114 + print OUT $line;
115 +diff --git a/t/fh_encrypt.t b/t/fh_encrypt.t
116 +index 35a74fb..e595ff9 100644
117 +--- a/t/fh_encrypt.t
118 ++++ b/t/fh_encrypt.t
119 +@@ -6,7 +6,7 @@ BEGIN
120 + }
121 +
122 + use strict;
123 +-use Test::More tests => 6;
124 ++use Test::More tests => 7;
125 + use_ok( 'Crypt::CipherSaber' );
126 +
127 + # tests the fh_crypt() method
128 +@@ -114,6 +114,44 @@ while (<SOURCE>)
129 +
130 + ok( ! $status, 'autogenerating and autoreading IV should also round-trip' );
131 +
132 ++# IV retrieved from encrypted file can contain new-line characters. Check that
133 ++# fh_encrypt can deal with it
134 ++{
135 ++ local $/ = "\012";
136 ++
137 ++ open( IN, 'smiles.png' ) or die "Cannot read smiles.png: $!";
138 ++ open( OUT, '> smiles_2.cs1' ) or die "Cannot write to smiles_2.cs1: $!";
139 ++ binmode( IN );
140 ++ binmode( OUT );
141 ++ $cs->fh_crypt( \*IN, \*OUT, $/ x 10 );
142 ++ close IN;
143 ++ close OUT;
144 ++
145 ++ open( IN, 'smiles_2.cs1' ) or die "Cannot read smiles_2.cs1: $!";
146 ++ open( OUT, '> smiles_2.png' ) or die "Cannot write to smiles_2.png $!";
147 ++ binmode( IN );
148 ++ binmode( OUT );
149 ++ $cs->fh_crypt( \*IN, \*OUT );
150 ++ close IN;
151 ++ close OUT;
152 ++
153 ++ open( SOURCE, 'smiles.png' ) or die "Cannot read smiles.png: $!";
154 ++ open( DEST, 'smiles_2.png' ) or die "Cannot read smiles_2.png: $!";
155 ++ binmode SOURCE;
156 ++ binmode DEST;
157 ++ $status = 0;
158 ++ while (<SOURCE>)
159 ++ {
160 ++ unless ($_ eq <DEST>)
161 ++ {
162 ++ $status = 1;
163 ++ last;
164 ++ }
165 ++ }
166 ++ ok( ! $status, 'IV with new-lines in the encrypted file' );
167 ++}
168 ++
169 ++
170 + END
171 + {
172 + 1 while unlink qw( smiles_2.cs1 smiles_2.png outsmiles.cs1 outsmiles.png );
173 +--
174 +2.14.1
175 +