Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RangeCheckError in JEDI WSCL

I'm using JEDI WSCL to change permissions on a folder during installation. When compiling without Optimization, and with Range Checking, I get a rangecheck when setting the new Access Control List.

procedure SetFilePermissions(const folder: string);
var
  FileObject: TJwSecureFileObject;
  DACL: TJwDAccessControlList;
begin
  FileObject := TJwSecureFileObject.Create(folder);
  try
     DACL := FileObject.DACL;
     JwInitWellknownSIDs;
     DACL.Add(TJwDiscretionaryAccessControlEntryAllow.Create(nil, [afObjectInheritAce],   GENERIC_ALL, JwWorldSID, false));
     FileObject.SetDACL(DACL);
  finally
    FileObject.Free;
  end;
end;

It lookes like it comes from function TJwSecurityId.CreateCopyOfSID( ) in JwsclSid.pas, but I can not find out why.

Do anybody have any clue?

I'm using Delphi 2007, btw, and the wscl code is the latest from sourceforge.

regards,
-Vegar

like image 461
Vegar Avatar asked Nov 21 '25 08:11

Vegar


1 Answers

The reason is the declaration of the PSID structure. It has a memeber called SubAuthority that is defined as follow:

SubAuthority: array [0..ANYSIZE_ARRAY - 1] of DWORD;

ANYSIZE_ARRAY is a constant that is set to 1 and thus the range of the array is 0 to 0. This is a c construct converted to Delphi but Delphi doesn't know it. The structure is created safely by allocating enough space to allow more than just one DWORD in the array.

This exception happens quite often if you are using variable c structures in Delphi with activated range check error.

However, as a solution you can turn off the switch for JWSCL by opening the jwscl.inc file and add {$R-}. AFAIK the switch lasts only to the end of each unit and then the default value is used. The inc file is included in every single jwscl file.

like image 170
ChristianWimmer Avatar answered Nov 24 '25 04:11

ChristianWimmer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!