From ff6975332f87a16517b7d2619c58fa47c3a33f97 Mon Sep 17 00:00:00 2001
From: Steve Maier <82616727+SteveMaier-IRT@users.noreply.github.com>
Date: Sat, 17 Sep 2022 00:07:14 -0400
Subject: [PATCH] Removed the use of the size of data returned from the C++
just use normal string logic. (#331)
---
.../ElectionGuard/ElectionGuard.Encryption/Ballot.cs | 6 +++---
.../ElectionGuard/ElectionGuard.Encryption/Election.cs | 2 +-
.../ElectionGuard.Encryption.csproj | 8 ++++----
.../ElectionGuard/ElectionGuard.Encryption/Encrypt.cs | 2 +-
.../ElectionGuard/ElectionGuard.Encryption/Group.cs | 2 +-
.../ElectionGuard/ElectionGuard.Encryption/Manifest.cs | 4 ++--
6 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot.cs b/bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot.cs
index e22d71a..155dd68 100644
--- a/bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot.cs
+++ b/bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot.cs
@@ -909,7 +909,7 @@ public unsafe string ToJson()
var status = NativeInterface.PlaintextBallot.ToJson(
Handle, out IntPtr pointer, out ulong size);
status.ThrowIfError();
- var json = Marshal.PtrToStringAnsi(pointer, (int)size);
+ var json = Marshal.PtrToStringAnsi(pointer);
NativeInterface.Memory.FreeIntPtr(pointer);
return json;
}
@@ -1242,7 +1242,7 @@ public unsafe string ToJson(bool withNonces = false)
: NativeInterface.CiphertextBallot.ToJson(
Handle, out pointer, out size);
status.ThrowIfError();
- var json = Marshal.PtrToStringAnsi(pointer, (int)size);
+ var json = Marshal.PtrToStringAnsi(pointer);
NativeInterface.Memory.FreeIntPtr(pointer);
return json;
}
@@ -1609,7 +1609,7 @@ public unsafe string ToJson()
var status = NativeInterface.SubmittedBallot.ToJson(
Handle, out IntPtr pointer, out ulong size);
status.ThrowIfError();
- var json = Marshal.PtrToStringAnsi(pointer, (int)size);
+ var json = Marshal.PtrToStringAnsi(pointer);
NativeInterface.Memory.FreeIntPtr(pointer);
return json;
}
diff --git a/bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Election.cs b/bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Election.cs
index 1d2e149..72cec02 100644
--- a/bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Election.cs
+++ b/bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Election.cs
@@ -316,7 +316,7 @@ public unsafe string ToJson()
var status = NativeInterface.CiphertextElectionContext.ToJson(
Handle, out IntPtr pointer, out ulong size);
status.ThrowIfError();
- var json = Marshal.PtrToStringAnsi(pointer, (int)size);
+ var json = Marshal.PtrToStringAnsi(pointer);
NativeInterface.Memory.FreeIntPtr(pointer);
return json;
}
diff --git a/bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/ElectionGuard.Encryption.csproj b/bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/ElectionGuard.Encryption.csproj
index d5e57b0..e4584b4 100644
--- a/bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/ElectionGuard.Encryption.csproj
+++ b/bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/ElectionGuard.Encryption.csproj
@@ -7,9 +7,9 @@
ElectionGuard
ElectionGuard.Encryption
- 0.1.17
- 0.1.17.0
- 0.1.17.0
+ 0.1.18
+ 0.1.18.0
+ 0.1.18.0
@@ -19,7 +19,7 @@
ElectionGuard Encryption
Open source implementation of ElectionGuard's ballot encryption.
Microsoft
- 0.1.17
+ 0.1.18
MIT
https://github.com/microsoft/electionguard-cpp
https://github.com/microsoft/electionguard-cpp
diff --git a/bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Encrypt.cs b/bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Encrypt.cs
index 77b8f72..d422d16 100644
--- a/bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Encrypt.cs
+++ b/bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Encrypt.cs
@@ -68,7 +68,7 @@ public unsafe string ToJson()
{
var status = NativeInterface.EncryptionDevice.ToJson(Handle, out IntPtr pointer, out ulong size);
status.ThrowIfError();
- var json = Marshal.PtrToStringAnsi(pointer, (int)size);
+ var json = Marshal.PtrToStringAnsi(pointer);
NativeInterface.Memory.FreeIntPtr(pointer);
return json;
}
diff --git a/bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Group.cs b/bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Group.cs
index b4a0f07..03e485d 100644
--- a/bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Group.cs
+++ b/bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Group.cs
@@ -415,7 +415,7 @@ public unsafe static string ToJson()
var status = NativeInterface.Constants.ToJson(
out IntPtr pointer, out ulong size);
status.ThrowIfError();
- var json = Marshal.PtrToStringAnsi(pointer, (int)size);
+ var json = Marshal.PtrToStringAnsi(pointer);
NativeInterface.Memory.FreeIntPtr(pointer);
return json;
}
diff --git a/bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Manifest.cs b/bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Manifest.cs
index 1f1d727..6fd178e 100644
--- a/bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Manifest.cs
+++ b/bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Manifest.cs
@@ -2454,7 +2454,7 @@ public unsafe string ToJson()
{
throw new ElectionGuardException($"ToJson Error Status: {status}");
}
- var json = Marshal.PtrToStringAnsi(pointer, (int)size);
+ var json = Marshal.PtrToStringAnsi(pointer);
NativeInterface.Memory.FreeIntPtr(pointer);
return json;
}
@@ -2681,7 +2681,7 @@ public unsafe string ToJson()
{
throw new ElectionGuardException($"ToJson Error Status: {status}");
}
- var json = Marshal.PtrToStringAnsi(pointer, (int)size);
+ var json = Marshal.PtrToStringAnsi(pointer);
NativeInterface.Memory.FreeIntPtr(pointer);
return json;
}