Skip to content

Commit

Permalink
Write the length field when writing a VT_BLOB property
Browse files Browse the repository at this point in the history
  • Loading branch information
Numpsy committed Apr 23, 2024
1 parent 591eaea commit 14b6b1c
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 14b6b1c

Please sign in to comment.