Einzelnen Beitrag anzeigen

bernhard_LA

Registriert seit: 8. Jun 2009
Ort: Bayern
1.123 Beiträge
 
Delphi 11 Alexandria
 
#1

TLockbox , stream fehler

  Alt 10. Mai 2017, 13:48
wir bekommen beim ver /entschlüsseln mit LOCKBOX unter DELPHI 10.1 einen "random" Zugriffsfehler RANGE CHECK ERROR , log des fehlers mit MADSHI siehe screen dump
CodeZeile : ThreeBytes[ByteIdx] := ThreeBytes[ByteIdx] + (Bits6 shl (8 - BitIdx));[/I


Delphi-Quellcode:
procedure CustomBase64_to_stream( const Base64: TBytes; Destin: TStream;
  const InverseTransform: TInverseBaseTransform);
var
  P, j, i: integer;
  Ch: Byte;
  Bits6: byte;
  ThreeBytes: packed array[ 0..2 ] of byte;
  ByteIdx, BitIdx: integer;
// ShrN: integer;
  Addend: byte;
begin
{$IFDEF DEBUG}
  {$RANGECHECKS OFF}
{$ENDIF}

// Assume Destin is already at the desired postion and size.
for P := 0 to (Length( Base64) div 4) - 1 do
  begin
  for i := 0 to 2 do ThreeBytes[i] := 0;
  ByteIdx := 0;
  BitIdx := 0;
  for j := 1 to 4 do
    begin
    Ch := Base64[ P * 4 + j - 1];
    if Ch = Ord('=') then break;
    Bits6 := InverseTransform[ Ch];
// ShrN := BitIdx - 2;
    if BitIdx > 2 then
        Addend := Bits6 shr (BitIdx - 2)
      else if BitIdx = 2 then
        Addend := Bits6
      else
        Addend := Bits6 shl (2 - BitIdx);
    ThreeBytes[ ByteIdx ] := ThreeBytes[ ByteIdx ] + Addend;
    Inc( BitIdx, 6);
    if BitIdx >= 8 then
      begin
      Dec( BitIdx, 8);
      Inc( ByteIdx);
      if BitIdx > 0 then
        ThreeBytes[ByteIdx] := ThreeBytes[ByteIdx] + (Bits6 shl (8 - BitIdx));
      end
    end;
  Destin.WriteBuffer( ThreeBytes, ByteIdx)
  end
  {$IFDEF DEBUG}
  {$RANGECHECKS ON}
{$ENDIF}

end;
Miniaturansicht angehängter Grafiken
lockbox_issues.jpg   lockbox_issues_3.jpg  

Geändert von bernhard_LA (10. Mai 2017 um 22:15 Uhr)
  Mit Zitat antworten Zitat