For the life of me, I cannot figure out why I cannot reproduce this error outside of my main project. This is with Perl 5.20 and I am trying to get the security information for a registry key. Here is the code as written in my main project followed by a code snippet that I have tried running outside of the project to reproduce the error.
sub getEffectiveRights { my $object = $_[1]; my $objectType = $_[2]; my $binarySid = $_[3]; my $error = undef; my $result = undef; # Establish variables. my $psidOwner; my $psidGroup; my $pDacl; my $pSacl; my $pSecurityDescriptor; try { $logger->debug("Object: $object"); # Call GetNamedSecurityInfo. This is to get the DACL. ($psidOwner, $psidGroup, $pDacl, $pSacl, $pSecurityDescriptor) + = Win32::Security::Raw::GetNamedSecurityInfo( $object, $objectType, 'DACL_SECURITY_INFORMATION'); print "returned from Win32::Security::Raw::GetNamedSecurityInf +o\n"; unless (defined($pDacl)) { throw Error::Simple("An error occurred trying to access th +e discretionary access control entries for security object '" . $obje +ct . "'."); } # Build the trustee structure. my $trustee = System_Functions->buildTrusteeWithSid($binarySid +); # Get the access mask. $result = System_Functions->getEffectiveRightsFromAcl($pDacl, +$trustee); } catch Error::Simple with { $error = shift; print "error = $error\n"; } finally { # Clear memory. if (defined($pSecurityDescriptor)) { Win32::Security::Raw::LocalFree($pSecurityDescriptor); } }; if (defined($error)) { throw Error::Simple("Could not access '$object'. Verify that i +t exists and that you have permission to access it. $error"); } return $result; }
And the script that works outside of the main project:
use warnings; use strict; use Win32::Security::Raw; #my $object = "MACHINE\\SYSTEM\\CurrentControlSet\\Services"; my @objects = ("MACHINE\\SYSTEM\\CurrentControlSet\\services","MACHINE +\\SYSTEM\\CurrentControlSet\\Services","MACHINE\\SYSTEM\\CurrentContr +olSet\\services\\.NET CLR Data", "MACHINE\\SYSTEM\\CurrentControlSet\ +\services\\Lsa\\Performance"); my $ObjectType = 'SE_REGISTRY_KEY'; my $SecurityInfo = 'DACL_SECURITY_INFORMATION'; # Establish variables. my $psidOwner; my $psidGroup; my $pDacl; my $pSacl; my $pSecurityDescriptor; foreach my $object (@objects) { print "object = $object\n"; # Call GetNamedSecurityInfo. This is to get the DACL. ($psidOwner, $psidGroup, $pDacl, $pSacl, $pSecurityDescriptor) = W +in32::Security::Raw::GetNamedSecurityInfo($object, $ObjectType, 'DACL +_SECURITY_INFORMATION'); print "$psidOwner, $psidGroup, $pDacl, $pSacl, $pSecurityDescripto +r.\n"; if (defined($pSecurityDescriptor)) { Win32::Security::Raw::LocalFree($pSecurityDescriptor); } print "\n\n"; }
I noticed that Win32::API, which is called by Win32::Security::Raw, changed significantly since Perl 5.12 and now has buffer overflow protection built-in but I'm unsure why it would be complaining about "parameter 1". Any help would be greatly appreciative as this is preventing us from upgrading to Perl 5.20.

In reply to Win32::API::Call: parameter 1 had a buffer overflow at c:/Perl/site/lib/Win32/Security/Raw.pm line 242 by dt667

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.