[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [rbm/master] Bug 24361: fix handling of wide characters in sha256



commit 134cad4e79471d7baa82f00b4a6e2d7f7d11868a
Author: Nicolas Vigier <boklm@xxxxxxxxxxxxxx>
Date:   Mon Nov 20 17:55:23 2017 +0100

    Bug 24361: fix handling of wide characters in sha256
    
    The sha256_hex function gives an error if a string contains wide
    characters. To avoid this we first encode the string to utf8 (which
    transforms it to a sequence of octets), before passing it to sha256_hex.
---
 lib/RBM.pm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/RBM.pm b/lib/RBM.pm
index 96a1b9b..3134efe 100644
--- a/lib/RBM.pm
+++ b/lib/RBM.pm
@@ -2,6 +2,7 @@ package RBM;
 
 use warnings;
 use strict;
+use Encode qw(encode);
 use Cwd qw(getcwd);
 use YAML::XS qw(LoadFile);
 use Template;
@@ -639,7 +640,9 @@ sub process_template {
         tmpl       => sub { process_template($project, $_[0], $dest_dir) },
         shell_quote => \&shell_quote,
         versioncmp  => \&versioncmp,
-        sha256      => \&sha256_hex,
+        sha256      => sub {
+            return sha256_hex(encode("utf8", $_[0]));
+        },
         sha256file  => \&sha256file,
         fileparse   => \&fileparse,
         ENV         => \%ENV,



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits