Skip to content

Commit

Permalink
Fix parsing DWORD keys from registry on Windows (#79)
Browse files Browse the repository at this point in the history
If the key is not in REG_SZ but REG_DWORD, value like "0x0000" should be read as a 0
  • Loading branch information
SteadEXE authored Feb 21, 2022
1 parent 8619b50 commit e151e79
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lib/GLPI/Agent/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e151e79

Please sign in to comment.