Skip to content

Commit

Permalink
Merge pull request #128 from Numpsy/users/rw/blob_length
Browse files Browse the repository at this point in the history
Write the length field when writing a VT_BLOB property
  • Loading branch information
ironfede authored May 31, 2024
2 parents 591eaea + 14b6b1c commit a61b6b9
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions sources/OpenMcdf.Extensions/OLEProperties/PropertyFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -647,17 +647,24 @@ public VT_CF_Property(VTPropertyType vType, bool isVariant) : base(vType, isVari
public override object ReadScalarValue(System.IO.BinaryReader br)
{

int size = br.ReadInt32();
byte[] data = br.ReadBytes(size);
uint size = br.ReadUInt32();
byte[] data = br.ReadBytes((int)size);
return data;
//br.ReadUInt16();//padding
}

public override void WriteScalarValue(BinaryWriter bw, object pValue)
{
byte[] r = pValue as byte[];
if (r != null)
if (r is null)
{
bw.Write(0u);
}
else
{
bw.Write((uint)r.Length);
bw.Write(r);
}
}

}
Expand All @@ -671,17 +678,23 @@ public VT_BLOB_Property(VTPropertyType vType, bool isVariant) : base(vType, isVa

public override object ReadScalarValue(System.IO.BinaryReader br)
{
int size = br.ReadInt32();
byte[] data = br.ReadBytes(size);
uint size = br.ReadUInt32();
byte[] data = br.ReadBytes((int)size);
return data;
}

public override void WriteScalarValue(BinaryWriter bw, object pValue)
{
byte[] r = pValue as byte[];
if (r != null)
if (r is null)
{
bw.Write(0u);
}
else
{
bw.Write((uint)r.Length);
bw.Write(r);

}
}

}
Expand Down

0 comments on commit a61b6b9

Please sign in to comment.