From 14b6b1c2a71347bce89e6e3a886392c8363baba0 Mon Sep 17 00:00:00 2001 From: Richard Webb Date: Fri, 19 Apr 2024 12:31:07 +0100 Subject: [PATCH] Write the length field when writing a VT_BLOB property --- .../OLEProperties/PropertyFactory.cs | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/sources/OpenMcdf.Extensions/OLEProperties/PropertyFactory.cs b/sources/OpenMcdf.Extensions/OLEProperties/PropertyFactory.cs index 438cf7ae..af36bad1 100644 --- a/sources/OpenMcdf.Extensions/OLEProperties/PropertyFactory.cs +++ b/sources/OpenMcdf.Extensions/OLEProperties/PropertyFactory.cs @@ -647,8 +647,8 @@ 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 } @@ -656,8 +656,15 @@ public override object ReadScalarValue(System.IO.BinaryReader br) 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); + } } } @@ -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); - + } } }