LibCecSharp: fixed buffer overrun when copying libcec_configuration. fixes crash...
authorLars Op den Kamp <lars@opdenkamp.eu>
Tue, 8 May 2012 09:15:55 +0000 (11:15 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Tue, 8 May 2012 09:15:55 +0000 (11:15 +0200)
src/LibCecSharp/LibCecSharp.cpp

index 680ccfba6f2ffa51b549e145c202c1c78cb3a97f..fb723236eb0fa4fd3892dbc7b65c8ff3aa050d9f 100644 (file)
@@ -91,7 +91,8 @@ namespace CecSharp
                {
                        config.Clear();
 
-                       _snprintf_s(config.strDeviceName, 13, context->marshal_as<const char*>(netConfig->DeviceName));
+                       const char *strDeviceName = context->marshal_as<const char*>(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<const char*>(netConfig->DeviceLanguage));
+                       {
+                               const char *strDeviceLanguage = context->marshal_as<const char*>(netConfig->DeviceLanguage);
+                               memcpy_s(config.strDeviceLanguage, 3, strDeviceLanguage, 3);
+                       }
 
                        config.callbacks            = &g_cecCallbacks;
                }