From e151e79d3c5ffafe362a9b99d623bfd562a9fa0f Mon Sep 17 00:00:00 2001 From: Jordan B Date: Mon, 21 Feb 2022 18:07:11 +0100 Subject: [PATCH] Fix parsing DWORD keys from registry on Windows (#79) If the key is not in REG_SZ but REG_DWORD, value like "0x0000" should be read as a 0 --- lib/GLPI/Agent/Config.pm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/GLPI/Agent/Config.pm b/lib/GLPI/Agent/Config.pm index 04285a546..8b9b6e3ef 100644 --- a/lib/GLPI/Agent/Config.pm +++ b/lib/GLPI/Agent/Config.pm @@ -185,11 +185,17 @@ sub _loadFromRegistry { foreach my $rawKey (keys %$settings) { next unless $rawKey =~ /^\/(\S+)/; my $key = lc($1); - my $val = $settings->{$rawKey}; - # Remove the quotes - $val =~ s/\s+$//; - $val =~ s/^'(.*)'$/$1/; - $val =~ s/^"(.*)"$/$1/; + my ($val, $type) = $settings->GetValue($key); + + if ($type == Win32::TieRegistry::REG_SZ()) { + $val =~ s/\s+$//; + $val =~ s/^'(.*)'$/$1/; + $val =~ s/^"(.*)"$/$1/; + } + + if ($type == Win32::TieRegistry::REG_DWORD()) { + $val = hex($val); + } if (exists $default->{$key}) { $self->{$key} = $val;