[pve-devel] [PATCH pve-cluster] Remove decode from log_msg

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Oct 28 18:01:02 CET 2015


decode('utf8', $msg) expects $msg to be an sequence of octets with
Perls internal encoding - thus no octect may be an wide character,
or in other words have a character bigger than 255.
In this context decode doesn't really makes sense and can easily
fail if we want to log an message including an utf8 character.
The text is alreayde decoded.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---

Proposal, maybe there is some better way.

This fixes bug 790.


 data/PVE/Cluster.pm | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/data/PVE/Cluster.pm b/data/PVE/Cluster.pm
index 554ec0b..5575e15 100644
--- a/data/PVE/Cluster.pm
+++ b/data/PVE/Cluster.pm
@@ -963,12 +963,10 @@ sub log_msg {
    $msg = "empty message" if !$msg;
 
    $ident = "" if !$ident;
-   $ident = encode("ascii", decode_utf8($ident),
+   $ident = encode("ascii", $ident,
 		   sub { sprintf "\\u%04x", shift });
 
-   my $utf8 = decode_utf8($msg);
-
-   my $ascii = encode("ascii", $utf8, sub { sprintf "\\u%04x", shift });
+   my $ascii = encode("ascii", $msg, sub { sprintf "\\u%04x", shift });
 
    if ($ident) {
        syslog($priority, "<%s> %s", $ident, $ascii);
-- 
2.1.4





More information about the pve-devel mailing list