Skip to content

Commit ae92af0

Browse files
committed
Revert to use vsprintf_s; increase buffer size
1 parent 35ffa21 commit ae92af0

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/MirrorInternalLogs/Util/LibcHelper.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ namespace MirrorInternalLogs.Util
88
{
99
internal static class LibcHelper
1010
{
11-
[DynDllImport("libc", "vsprintf")] private static readonly VsPrintFsDelegate VsPrintF = null;
11+
[DynDllImport("libc", "vsprintf_s")] private static readonly VsPrintFsDelegate VsPrintF = null;
1212

13-
public static string Format(IntPtr format, IntPtr args, int buffer = 8192)
13+
public static string Format(IntPtr format, IntPtr args, int buffer = ushort.MaxValue)
1414
{
1515
var sb = new StringBuilder(buffer);
16-
VsPrintF(sb, format, args);
16+
VsPrintF(sb, sb.Capacity, format, args);
1717
return sb.ToString();
1818
}
1919

@@ -31,7 +31,6 @@ public static void Init()
3131
}
3232

3333
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
34-
private delegate int VsPrintFsDelegate([MarshalAs(UnmanagedType.LPStr)] StringBuilder dest, IntPtr fmt,
35-
IntPtr vaList);
34+
private delegate int VsPrintFsDelegate([MarshalAs(UnmanagedType.LPStr)] StringBuilder dest, int bufferSize, IntPtr fmt, IntPtr vaList);
3635
}
3736
}

0 commit comments

Comments
 (0)