From db29649dbdb9cdc03d536cda78e48b525d146139 Mon Sep 17 00:00:00 2001 From: Jan-Ivar Bruaroey Date: Tue, 21 Jan 2020 21:59:34 +0000 Subject: [PATCH] Bug 1598543 - Use size instead of length. r=dminor Differential Revision: https://phabricator.services.mozilla.com/D58144 --HG-- extra : moz-landing-system : lando --- .../video_engine/desktop_capture_impl.cc | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/dom/media/systemservices/video_engine/desktop_capture_impl.cc b/dom/media/systemservices/video_engine/desktop_capture_impl.cc index ff71738b18c9..6fdb72a8ec50 100644 --- a/dom/media/systemservices/video_engine/desktop_capture_impl.cc +++ b/dom/media/systemservices/video_engine/desktop_capture_impl.cc @@ -57,21 +57,21 @@ uint32_t ScreenDeviceInfoImpl::NumberOfDevices() { } int32_t ScreenDeviceInfoImpl::GetDeviceName( - uint32_t deviceNumber, char* deviceNameUTF8, uint32_t deviceNameUTF8Length, - char* deviceUniqueIdUTF8, uint32_t deviceUniqueIdUTF8Length, - char* productUniqueIdUTF8, uint32_t productUniqueIdUTF8Length, pid_t* pid) { + uint32_t deviceNumber, char* deviceNameUTF8, uint32_t deviceNameUTF8Size, + char* deviceUniqueIdUTF8, uint32_t deviceUniqueIdUTF8Size, + char* productUniqueIdUTF8, uint32_t productUniqueIdUTF8Size, pid_t* pid) { DesktopDisplayDevice desktopDisplayDevice; // always initialize output - if (deviceNameUTF8 && deviceNameUTF8Length > 0) { - memset(deviceNameUTF8, 0, deviceNameUTF8Length); + if (deviceNameUTF8 && deviceNameUTF8Size > 0) { + memset(deviceNameUTF8, 0, deviceNameUTF8Size); } - if (deviceUniqueIdUTF8 && deviceUniqueIdUTF8Length > 0) { - memset(deviceUniqueIdUTF8, 0, deviceUniqueIdUTF8Length); + if (deviceUniqueIdUTF8 && deviceUniqueIdUTF8Size > 0) { + memset(deviceUniqueIdUTF8, 0, deviceUniqueIdUTF8Size); } - if (productUniqueIdUTF8 && productUniqueIdUTF8Length > 0) { - memset(productUniqueIdUTF8, 0, productUniqueIdUTF8Length); + if (productUniqueIdUTF8 && productUniqueIdUTF8Size > 0) { + memset(productUniqueIdUTF8, 0, productUniqueIdUTF8Size); } if (desktop_device_info_->getDesktopDisplayDeviceInfo( @@ -80,13 +80,13 @@ int32_t ScreenDeviceInfoImpl::GetDeviceName( const char* deviceName = desktopDisplayDevice.getDeviceName(); len = deviceName ? strlen(deviceName) : 0; - if (len && deviceNameUTF8 && len <= deviceNameUTF8Length) { + if (len && deviceNameUTF8 && len < deviceNameUTF8Size) { memcpy(deviceNameUTF8, deviceName, len); } const char* deviceUniqueId = desktopDisplayDevice.getUniqueIdName(); len = deviceUniqueId ? strlen(deviceUniqueId) : 0; - if (len && deviceUniqueIdUTF8 && len <= deviceUniqueIdUTF8Length) { + if (len && deviceUniqueIdUTF8 && len < deviceUniqueIdUTF8Size) { memcpy(deviceUniqueIdUTF8, deviceUniqueId, len); } } @@ -143,20 +143,20 @@ uint32_t AppDeviceInfoImpl::NumberOfDevices() { } int32_t AppDeviceInfoImpl::GetDeviceName( - uint32_t deviceNumber, char* deviceNameUTF8, uint32_t deviceNameUTF8Length, - char* deviceUniqueIdUTF8, uint32_t deviceUniqueIdUTF8Length, - char* productUniqueIdUTF8, uint32_t productUniqueIdUTF8Length, pid_t* pid) { + uint32_t deviceNumber, char* deviceNameUTF8, uint32_t deviceNameUTF8Size, + char* deviceUniqueIdUTF8, uint32_t deviceUniqueIdUTF8Size, + char* productUniqueIdUTF8, uint32_t productUniqueIdUTF8Size, pid_t* pid) { DesktopApplication desktopApplication; // always initialize output - if (deviceNameUTF8Length && deviceNameUTF8Length > 0) { - memset(deviceNameUTF8, 0, deviceNameUTF8Length); + if (deviceNameUTF8Size && deviceNameUTF8Size > 0) { + memset(deviceNameUTF8, 0, deviceNameUTF8Size); } - if (deviceUniqueIdUTF8 && deviceUniqueIdUTF8Length > 0) { - memset(deviceUniqueIdUTF8, 0, deviceUniqueIdUTF8Length); + if (deviceUniqueIdUTF8 && deviceUniqueIdUTF8Size > 0) { + memset(deviceUniqueIdUTF8, 0, deviceUniqueIdUTF8Size); } - if (productUniqueIdUTF8 && productUniqueIdUTF8Length > 0) { - memset(productUniqueIdUTF8, 0, productUniqueIdUTF8Length); + if (productUniqueIdUTF8 && productUniqueIdUTF8Size > 0) { + memset(productUniqueIdUTF8, 0, productUniqueIdUTF8Size); } if (desktop_device_info_->getApplicationInfo(deviceNumber, @@ -165,13 +165,13 @@ int32_t AppDeviceInfoImpl::GetDeviceName( const char* deviceName = desktopApplication.getProcessAppName(); len = deviceName ? strlen(deviceName) : 0; - if (len && len <= deviceNameUTF8Length) { + if (len && len < deviceNameUTF8Size) { memcpy(deviceNameUTF8, deviceName, len); } const char* deviceUniqueId = desktopApplication.getUniqueIdName(); len = deviceUniqueId ? strlen(deviceUniqueId) : 0; - if (len && deviceUniqueIdUTF8 && len <= deviceUniqueIdUTF8Length) { + if (len && deviceUniqueIdUTF8 && len < deviceUniqueIdUTF8Size) { memcpy(deviceUniqueIdUTF8, deviceUniqueId, len); } if (pid) { @@ -231,20 +231,20 @@ uint32_t WindowDeviceInfoImpl::NumberOfDevices() { } int32_t WindowDeviceInfoImpl::GetDeviceName( - uint32_t deviceNumber, char* deviceNameUTF8, uint32_t deviceNameUTF8Length, - char* deviceUniqueIdUTF8, uint32_t deviceUniqueIdUTF8Length, - char* productUniqueIdUTF8, uint32_t productUniqueIdUTF8Length, pid_t* pid) { + uint32_t deviceNumber, char* deviceNameUTF8, uint32_t deviceNameUTF8Size, + char* deviceUniqueIdUTF8, uint32_t deviceUniqueIdUTF8Size, + char* productUniqueIdUTF8, uint32_t productUniqueIdUTF8Size, pid_t* pid) { DesktopDisplayDevice desktopDisplayDevice; // always initialize output - if (deviceNameUTF8 && deviceNameUTF8Length > 0) { - memset(deviceNameUTF8, 0, deviceNameUTF8Length); + if (deviceNameUTF8 && deviceNameUTF8Size > 0) { + memset(deviceNameUTF8, 0, deviceNameUTF8Size); } - if (deviceUniqueIdUTF8 && deviceUniqueIdUTF8Length > 0) { - memset(deviceUniqueIdUTF8, 0, deviceUniqueIdUTF8Length); + if (deviceUniqueIdUTF8 && deviceUniqueIdUTF8Size > 0) { + memset(deviceUniqueIdUTF8, 0, deviceUniqueIdUTF8Size); } - if (productUniqueIdUTF8 && productUniqueIdUTF8Length > 0) { - memset(productUniqueIdUTF8, 0, productUniqueIdUTF8Length); + if (productUniqueIdUTF8 && productUniqueIdUTF8Size > 0) { + memset(productUniqueIdUTF8, 0, productUniqueIdUTF8Size); } if (desktop_device_info_->getWindowInfo(deviceNumber, desktopDisplayDevice) == @@ -253,13 +253,13 @@ int32_t WindowDeviceInfoImpl::GetDeviceName( const char* deviceName = desktopDisplayDevice.getDeviceName(); len = deviceName ? strlen(deviceName) : 0; - if (len && deviceNameUTF8 && len <= deviceNameUTF8Length) { + if (len && deviceNameUTF8 && len < deviceNameUTF8Size) { memcpy(deviceNameUTF8, deviceName, len); } const char* deviceUniqueId = desktopDisplayDevice.getUniqueIdName(); len = deviceUniqueId ? strlen(deviceUniqueId) : 0; - if (len && deviceUniqueIdUTF8 && len <= deviceUniqueIdUTF8Length) { + if (len && deviceUniqueIdUTF8 && len < deviceUniqueIdUTF8Size) { memcpy(deviceUniqueIdUTF8, deviceUniqueId, len); } if (pid) {