From 1d0b2f179049bb299227a311b2323024622b7826 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Tue, 8 May 2012 11:15:55 +0200 Subject: [PATCH] LibCecSharp: fixed buffer overrun when copying libcec_configuration. fixes crash when trying to save the configuration in the config gui. --- src/LibCecSharp/LibCecSharp.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/LibCecSharp/LibCecSharp.cpp b/src/LibCecSharp/LibCecSharp.cpp index 680ccfb..fb72323 100644 --- a/src/LibCecSharp/LibCecSharp.cpp +++ b/src/LibCecSharp/LibCecSharp.cpp @@ -91,7 +91,8 @@ namespace CecSharp { config.Clear(); - _snprintf_s(config.strDeviceName, 13, context->marshal_as(netConfig->DeviceName)); + const char *strDeviceName = context->marshal_as(netConfig->DeviceName); + memcpy_s(config.strDeviceName, 13, strDeviceName, 13); for (unsigned int iPtr = 0; iPtr < 5; iPtr++) config.deviceTypes.types[iPtr] = (cec_device_type)netConfig->DeviceTypes->Types[iPtr]; @@ -128,7 +129,10 @@ namespace CecSharp } if (netConfig->ServerVersion >= CecServerVersion::Version1_6_2) - _snprintf_s(config.strDeviceLanguage, 3, context->marshal_as(netConfig->DeviceLanguage)); + { + const char *strDeviceLanguage = context->marshal_as(netConfig->DeviceLanguage); + memcpy_s(config.strDeviceLanguage, 3, strDeviceLanguage, 3); + } config.callbacks = &g_cecCallbacks; } -- 2.34.1