Subject: | Win32::EventLog 0.074 produces warning «Use of uninitialized value in unpack at C:/Perl/site/lib/Win32/EventLog.pm line 126.» |
The Read() function in Win32::EventLog (Version 0.074) performs an
unpack operation on an uninitialized value if there was a failure
while reading the Event Log. This produces the warning
«Use of uninitialized value in unpack at
C:/Perl/site/lib/Win32/EventLog.pm line 126.»
This could be fixed simply by initialising the $header variable
I tested with success replacing the code:
my $result = ReadEventLog($self->{handle}, $readflags, $recordoffset,
my $header, my $source, my $computer, my
$sid,
my $data, my $strings);
with:
my $header = "";
my $result = ReadEventLog($self->{handle}, $readflags, $recordoffset,
$header, my $source, my $computer, my $sid,
my $data, my $strings);
The problem can be reproduced with the following test:
#!/usr/bin/perl -w
use warnings;
use strict;
use Win32::EventLog;
my $eventLog = Win32::EventLog->new('Application',Win32::NodeName())||
die $!;
my %event = ();
# Call read function with invalid parameter
$eventLog->Read(EVENTLOG_FORWARDS_READ|EVENTLOG_SEEK_READ,-1,\%event);
__END__
I used for this test:
v5.8.4 ActiveState Binary build 810
and
V5.8.8 ActiveState Binary build 819