Skip to content

Commit

Permalink
fix read if DATA field is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
b4tman committed Aug 12, 2021
1 parent 477eb72 commit 1c1ac2e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 29 deletions.
19 changes: 11 additions & 8 deletions PasswordChanger1C/DatabaseAccess8214.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,16 +341,19 @@ public static void ReadDataPage(ref AccessFunctions.PageParams PageHeader, strin
// двоичные данные неограниченной длины
// в рамках хранилища 8.3.6 их быть не должно


int DataPos = BitConverter.ToInt32(bytesBlock, Pos1);
int DataSize = BitConverter.ToInt32(bytesBlock, Pos1 + 4);
var BytesValTemp = GetBlobData(BlockBlob, DataPos, DataSize, reader);
var DataKey = new byte[1];
int DataKeySize = 0;
BytesVal = CommonModule.DecodePasswordStructure(BytesValTemp, ref DataKeySize, ref DataKey);
Dict.Add("DATA_KEYSIZE", DataKeySize);
Dict.Add("DATA_KEY", DataKey);
Dict.Add("DATA_BINARY", BytesValTemp);

if (DataSize > 0)
{
var BytesValTemp = GetBlobData(BlockBlob, DataPos, DataSize, reader);
var DataKey = new byte[1];
int DataKeySize = 0;
BytesVal = CommonModule.DecodePasswordStructure(BytesValTemp, ref DataKeySize, ref DataKey);
Dict.Add("DATA_KEYSIZE", DataKeySize);
Dict.Add("DATA_KEY", DataKey);
Dict.Add("DATA_BINARY", BytesValTemp);
}
}
else if (Field.Type == "NT")
{
Expand Down
47 changes: 26 additions & 21 deletions PasswordChanger1C/DatabaseAccess838.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,29 +135,34 @@ private static void ReadAllRecordsFromStoragePages(ref AccessFunctions.PageParam

int DataPos = BitConverter.ToInt32(bytesBlock, Pos1);
int DataSize = BitConverter.ToInt32(bytesBlock, Pos1 + 4);
if (Field.Name == "DATA")

if (DataSize > 0)
{
Dict.Add("DATA_POS", DataPos);
Dict.Add("DATA_SIZE", DataSize);
}

// Dim BytesValTemp = GetBlodDataByIndex(BlockBlob, DataPos, DataSize, reader, PageSize)
var BytesBlobBlock = new byte[PageSize];
reader.BaseStream.Seek(BlockBlob * PageSize, SeekOrigin.Begin);
reader.Read(BytesBlobBlock, 0, PageSize);
var BlobPage = ReadObjectPageDefinition(reader, BytesBlobBlock, PageSize);
BlobPage.BinaryData = ReadAllStoragePagesForObject(reader, BlobPage);
int[] argDataPositions = null;
var BytesValTemp = GetCleanDataFromBlob(DataPos, DataSize, BlobPage.BinaryData, DataPositions: ref argDataPositions);
// ***************************************


var DataKey = new byte[1];
int DataKeySize = 0;
BytesVal = CommonModule.DecodePasswordStructure(BytesValTemp, ref DataKeySize, ref DataKey);
Dict.Add("DATA_KEYSIZE", DataKeySize);
Dict.Add("DATA_KEY", DataKey);
Dict.Add("DATA_BINARY", BytesValTemp);
if (Field.Name == "DATA")
{
Dict.Add("DATA_POS", DataPos);
Dict.Add("DATA_SIZE", DataSize);
}

// Dim BytesValTemp = GetBlodDataByIndex(BlockBlob, DataPos, DataSize, reader, PageSize)
var BytesBlobBlock = new byte[PageSize];
reader.BaseStream.Seek(BlockBlob * PageSize, SeekOrigin.Begin);
reader.Read(BytesBlobBlock, 0, PageSize);
var BlobPage = ReadObjectPageDefinition(reader, BytesBlobBlock, PageSize);
BlobPage.BinaryData = ReadAllStoragePagesForObject(reader, BlobPage);
int[] argDataPositions = null;
var BytesValTemp = GetCleanDataFromBlob(DataPos, DataSize, BlobPage.BinaryData, DataPositions: ref argDataPositions);
// ***************************************


var DataKey = new byte[1];
int DataKeySize = 0;
BytesVal = CommonModule.DecodePasswordStructure(BytesValTemp, ref DataKeySize, ref DataKey);
Dict.Add("DATA_KEYSIZE", DataKeySize);
Dict.Add("DATA_KEY", DataKey);
Dict.Add("DATA_BINARY", BytesValTemp);
}
}
else if (Field.Type == "NT")
{
Expand Down

0 comments on commit 1c1ac2e

Please sign in to comment.