summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/moz-patch-stack/0026.patch
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/libwebrtc/moz-patch-stack/0026.patch
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/moz-patch-stack/0026.patch')
-rw-r--r--third_party/libwebrtc/moz-patch-stack/0026.patch148
1 files changed, 148 insertions, 0 deletions
diff --git a/third_party/libwebrtc/moz-patch-stack/0026.patch b/third_party/libwebrtc/moz-patch-stack/0026.patch
new file mode 100644
index 0000000000..ba8c50ed73
--- /dev/null
+++ b/third_party/libwebrtc/moz-patch-stack/0026.patch
@@ -0,0 +1,148 @@
+From: Gabriele Svelto <gsvelto@mozilla.com>
+Date: Mon, 28 Oct 2019 23:26:00 +0000
+Subject: Bug 1590984 - Use poll() instead of select() in WebRTC code r=drno
+
+The use of select() was leading to crashes when the file descriptor value was
+larger than FD_SETSIZE. Recent versions of glibc have checks in the FD_CLR(),
+FD_SET() and FD_ISSET() macros that will abort() the program instead of doing
+an out-of-bounds access. poll() doesn't have limitations on the file
+descriptor values and provides behavior that is otherwise identical to
+select() thus solving the problem.
+
+Differential Revision: https://phabricator.services.mozilla.com/D50798
+Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/59fb6760bb6785a6f8a51be6fc66bf04cfba3e16
+---
+ .../video_capture/linux/device_info_linux.cc | 1 +
+ .../video_capture/linux/device_info_v4l2.cc | 16 +++++-----
+ .../linux/video_capture_linux.cc | 1 +
+ .../video_capture/linux/video_capture_v4l2.cc | 29 +++++++++++--------
+ 4 files changed, 26 insertions(+), 21 deletions(-)
+
+diff --git a/modules/video_capture/linux/device_info_linux.cc b/modules/video_capture/linux/device_info_linux.cc
+index 9c12b2183e..4821cbccd5 100644
+--- a/modules/video_capture/linux/device_info_linux.cc
++++ b/modules/video_capture/linux/device_info_linux.cc
+@@ -10,6 +10,7 @@
+
+ #include <errno.h>
+ #include <fcntl.h>
++#include <poll.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+diff --git a/modules/video_capture/linux/device_info_v4l2.cc b/modules/video_capture/linux/device_info_v4l2.cc
+index 77968b7eaf..f87fe53abe 100644
+--- a/modules/video_capture/linux/device_info_v4l2.cc
++++ b/modules/video_capture/linux/device_info_v4l2.cc
+@@ -12,6 +12,7 @@
+
+ #include <errno.h>
+ #include <fcntl.h>
++#include <poll.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+@@ -73,16 +74,13 @@ void DeviceInfoV4l2::HandleEvent(inotify_event* event, int fd)
+
+ int DeviceInfoV4l2::EventCheck(int fd)
+ {
+- struct timeval timeout;
+- fd_set rfds;
++ struct pollfd fds = {
++ .fd = fd,
++ .events = POLLIN,
++ .revents = 0
++ };
+
+- timeout.tv_sec = 0;
+- timeout.tv_usec = 100000;
+-
+- FD_ZERO(&rfds);
+- FD_SET(fd, &rfds);
+-
+- return select(fd+1, &rfds, NULL, NULL, &timeout);
++ return poll(&fds, 1, 100);
+ }
+
+ int DeviceInfoV4l2::HandleEvents(int fd)
+diff --git a/modules/video_capture/linux/video_capture_linux.cc b/modules/video_capture/linux/video_capture_linux.cc
+index 4895a1ab71..f3324a8e68 100644
+--- a/modules/video_capture/linux/video_capture_linux.cc
++++ b/modules/video_capture/linux/video_capture_linux.cc
+@@ -10,6 +10,7 @@
+
+ #include <errno.h>
+ #include <fcntl.h>
++#include <poll.h>
+ #include <stdio.h>
+ #include <string.h>
+ #include <sys/ioctl.h>
+diff --git a/modules/video_capture/linux/video_capture_v4l2.cc b/modules/video_capture/linux/video_capture_v4l2.cc
+index 1dc13b01aa..b527a331e4 100644
+--- a/modules/video_capture/linux/video_capture_v4l2.cc
++++ b/modules/video_capture/linux/video_capture_v4l2.cc
+@@ -12,7 +12,7 @@
+
+ #include <errno.h>
+ #include <fcntl.h>
+-#include <linux/videodev2.h>
++#include <poll.h>
+ #include <stdio.h>
+ #include <string.h>
+ #include <sys/ioctl.h>
+@@ -20,6 +20,14 @@
+ #include <sys/select.h>
+ #include <time.h>
+ #include <unistd.h>
++// v4l includes
++#if defined(__NetBSD__) || defined(__OpenBSD__) // WEBRTC_BSD
++#include <sys/videoio.h>
++#elif defined(__sun)
++#include <sys/videodev2.h>
++#else
++#include <linux/videodev2.h>
++#endif
+
+ #include <new>
+ #include <string>
+@@ -359,16 +367,13 @@ bool VideoCaptureModuleV4L2::CaptureStarted() {
+
+ bool VideoCaptureModuleV4L2::CaptureProcess() {
+ int retVal = 0;
+- fd_set rSet;
+- struct timeval timeout;
++ struct pollfd rSet;
+
+- FD_ZERO(&rSet);
+- FD_SET(_deviceFd, &rSet);
+- timeout.tv_sec = 1;
+- timeout.tv_usec = 0;
++ rSet.fd = _deviceFd;
++ rSet.events = POLLIN;
++ rSet.revents = 0;
+
+- // _deviceFd written only in StartCapture, when this thread isn't running.
+- retVal = select(_deviceFd + 1, &rSet, NULL, NULL, &timeout);
++ retVal = poll(&rSet, 1, 1000);
+
+ {
+ MutexLock lock(&capture_lock_);
+@@ -378,12 +383,12 @@ bool VideoCaptureModuleV4L2::CaptureProcess() {
+ }
+
+ if (retVal < 0 && errno != EINTR) { // continue if interrupted
+- // select failed
++ // poll failed
+ return false;
+ } else if (retVal == 0) {
+- // select timed out
++ // poll timed out
+ return true;
+- } else if (!FD_ISSET(_deviceFd, &rSet)) {
++ } else if (!(rSet.revents & POLLIN)) {
+ // not event on camera handle
+ return true;
+ }
+--
+2.34.1
+