From 3cb200e51ecf0d04aadeda0a38e522f0103bb37e Mon Sep 17 00:00:00 2001 From: Marcello Maugeri Date: Sat, 28 Jun 2025 18:22:52 +0200 Subject: [PATCH 1/6] add obs-studio project --- projects/obs-studio/Dockerfile | 44 +++++++++++++ projects/obs-studio/build.sh | 62 +++++++++++++++++++ .../obs-studio/fuzz_util_bitstream_reader.cpp | 16 +++++ projects/obs-studio/project.yaml | 8 +++ 4 files changed, 130 insertions(+) create mode 100644 projects/obs-studio/Dockerfile create mode 100644 projects/obs-studio/build.sh create mode 100644 projects/obs-studio/fuzz_util_bitstream_reader.cpp create mode 100644 projects/obs-studio/project.yaml diff --git a/projects/obs-studio/Dockerfile b/projects/obs-studio/Dockerfile new file mode 100644 index 000000000000..b66fc9619773 --- /dev/null +++ b/projects/obs-studio/Dockerfile @@ -0,0 +1,44 @@ +FROM gcr.io/oss-fuzz-base/base-builder + +# Install OBS dependencies and ffmpeg build dependencies +RUN apt-get update && apt-get install -y \ + # OBS dependencies + libx264-dev libcurl4-openssl-dev libmbedtls-dev libgl1-mesa-dev libjansson-dev \ + libluajit-5.1-dev python3-dev libx11-dev libxcb-randr0-dev libxcb-shm0-dev libxcb-xinerama0-dev \ + libxcb-composite0-dev libxcomposite-dev libxinerama-dev libxcb1-dev libx11-xcb-dev libxcb-xfixes0-dev \ + swig libcmocka-dev libxss-dev libglvnd-dev libgles2-mesa libgles2-mesa-dev ninja-build \ + libpci-dev libqrcodegencpp-dev uthash-dev software-properties-common \ + extra-cmake-modules uuid-dev libpulse-dev libdrm-dev \ + # FFmpeg build dependencies + build-essential yasm nasm libvpx-dev libmp3lame-dev libopus-dev wget bzip2 + +RUN apt-get install -y pkg-config +# Download, build, and install FFmpeg 6.1.1 +RUN cd /tmp && \ + wget https://ffmpeg.org/releases/ffmpeg-6.1.1.tar.bz2 && \ + tar xjvf ffmpeg-6.1.1.tar.bz2 && \ + cd ffmpeg-6.1.1 && \ + env CFLAGS="" CXXFLAGS="" LDFLAGS="" ./configure \ + --prefix=/usr/local \ + --enable-shared \ + --enable-gpl \ + --enable-libx264 \ + --enable-libvpx \ + --enable-libmp3lame \ + --enable-libopus && \ + make -j$(nproc) && \ + make install && \ + ldconfig && \ + # Clean up source files to reduce final image size + cd / && rm -rf /tmp/ffmpeg-6.1.1* + +RUN add-apt-repository ppa:okirby/qt6-backports +RUN apt update +RUN apt-get install -y qt6-tools-dev libqt6svg6-dev libqt6xml6 qt6-base-dev libqt6widgets6 nlohmann-json3-dev libqt6svg6 libxkbcommon-dev qt6-base-private-dev + +# Clone OBS Studio and set up for the build +RUN git clone --recursive https://github.com/obsproject/obs-studio.git obs-studio +WORKDIR obs-studio + +COPY build.sh $SRC +COPY fuzz_*.cpp $SRC \ No newline at end of file diff --git a/projects/obs-studio/build.sh b/projects/obs-studio/build.sh new file mode 100644 index 000000000000..29e587269bf5 --- /dev/null +++ b/projects/obs-studio/build.sh @@ -0,0 +1,62 @@ +: ${LD:="${CXX}"} +: ${LDFLAGS:="${CXXFLAGS}"} # to make sure we link with sanitizer runtime + +cmake_args=( + -DCMAKE_BUILD_TYPE=Debug + -DENABLE_SCRIPTING=OFF + -DENABLE_PLUGINS=OFF + #-DENABLE_NEW_MPEGTS_OUTPUT=OFF #Used in obs-ffmpeg plugin which is not built + #-DENABLE_PIPEWIRE=OFF # Plugins are not buit, so this is not needed + -DENABLE_TESTS=ON + -DENABLE_UI=OFF + -DENABLE_FRONTEND=OFF + -DENABLE_WAYLAND=OFF + #-DENABLE_RELOCATABLE=ON + #-DENABLE_PORTABLE_CONFIG=ON + -DENABLE_STATIC=ON + -DBUILD_SHARED_LIBS=OFF + + # C compiler + -DCMAKE_C_COMPILER="${CC}" + -DCMAKE_C_FLAGS="${CFLAGS}" + # C++ compiler + -DCMAKE_CXX_COMPILER="${CXX}" + -DCMAKE_CXX_FLAGS="${CXXFLAGS}" + # Linker + -DCMAKE_LINKER="${LD}" + -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" + -DCMAKE_MODULE_LINKER_FLAGS="${LDFLAGS}" + -DCMAKE_SHARED_LINKER_FLAGS="${LDFLAGS}" +) + +# Temporary fixes as libobs is not built as a static library by default +# 1) turn libobs into a STATIC lib +sed -i 's#^add_library(libobs SHARED)#add_library(libobs STATIC)#' libobs/CMakeLists.txt +# 2) only export when NOT static (so the install/export step won’t fail) +sed -i '/^target_export(libobs)$/c\ +if(NOT ENABLE_STATIC)\ + target_export(libobs)\ +endif()' libobs/CMakeLists.txt +# 3) enable -fPIC on the static lib so it can be linked into .so’s +sed -i '/add_library(libobs STATIC)/a \ +set_target_properties(libobs PROPERTIES POSITION_INDEPENDENT_CODE ON)' libobs/CMakeLists.txt +# 4) build libobs-opengl as a static lib as well +sed -i -e 's#^add_library(libobs-opengl SHARED)#add_library(libobs-opengl STATIC)#' \ + -e '/add_library(libobs-opengl STATIC)/a\ +set_target_properties(libobs-opengl PROPERTIES POSITION_INDEPENDENT_CODE ON)' \ + libobs-opengl/CMakeLists.txt + + +mkdir -p obs-build +cmake -S . -B obs-build "${cmake_args[@]}" +cmake --build obs-build -- -k -j$(nproc) + +# Build the fuzz target +$CXX $CXXFLAGS -std=c++17 \ + -I$SRC/obs-studio/libobs \ + -I$SRC/obs-studio/obs-build/libobs \ + $SRC/fuzz_util_bitstream_reader.cpp \ + /src/obs-studio/obs-build/libobs/libobs.a \ + -lpthread -ldl -lm \ + -o $OUT/fuzz_util_bitstream_reader \ + $LIB_FUZZING_ENGINE diff --git a/projects/obs-studio/fuzz_util_bitstream_reader.cpp b/projects/obs-studio/fuzz_util_bitstream_reader.cpp new file mode 100644 index 000000000000..92072584a8fd --- /dev/null +++ b/projects/obs-studio/fuzz_util_bitstream_reader.cpp @@ -0,0 +1,16 @@ +#include + +#include + + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { + struct bitstream_reader reader; + // Get data from the fuzzer + FuzzedDataProvider stream(data, size); + + bitstream_reader_init(&reader, const_cast(data), size); + + bitstream_reader_read_bits(&reader, size * 8); + + return 0; +} \ No newline at end of file diff --git a/projects/obs-studio/project.yaml b/projects/obs-studio/project.yaml new file mode 100644 index 000000000000..df58247fe8b3 --- /dev/null +++ b/projects/obs-studio/project.yaml @@ -0,0 +1,8 @@ +homepage: "https://obsproject.com/" +language: c +primary_contact: "todo@mail.com" +sanitizers: +- address +- undefined +- memory +main_repo: 'https://github.com/obsproject/obs-studio/' From 3b1b6823faa6b2558b259239bd7254f9c2253e27 Mon Sep 17 00:00:00 2001 From: Marcello Maugeri Date: Sat, 28 Jun 2025 18:23:25 +0200 Subject: [PATCH 2/6] fix comment --- projects/obs-studio/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/obs-studio/build.sh b/projects/obs-studio/build.sh index 29e587269bf5..61dab5b6caa8 100644 --- a/projects/obs-studio/build.sh +++ b/projects/obs-studio/build.sh @@ -37,7 +37,7 @@ sed -i '/^target_export(libobs)$/c\ if(NOT ENABLE_STATIC)\ target_export(libobs)\ endif()' libobs/CMakeLists.txt -# 3) enable -fPIC on the static lib so it can be linked into .so’s +# 3) enable -fPIC on the static lib so it can be linked sed -i '/add_library(libobs STATIC)/a \ set_target_properties(libobs PROPERTIES POSITION_INDEPENDENT_CODE ON)' libobs/CMakeLists.txt # 4) build libobs-opengl as a static lib as well From 26083ac3b1d5311e7a3c1aa0c64617ed93605db3 Mon Sep 17 00:00:00 2001 From: Marcello Maugeri Date: Sat, 28 Jun 2025 18:32:53 +0200 Subject: [PATCH 3/6] add license headers --- projects/obs-studio/Dockerfile | 16 ++++++++++++++++ projects/obs-studio/build.sh | 16 ++++++++++++++++ .../obs-studio/fuzz_util_bitstream_reader.cpp | 12 ++++++++++++ 3 files changed, 44 insertions(+) diff --git a/projects/obs-studio/Dockerfile b/projects/obs-studio/Dockerfile index b66fc9619773..9fa57149a072 100644 --- a/projects/obs-studio/Dockerfile +++ b/projects/obs-studio/Dockerfile @@ -1,3 +1,19 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + FROM gcr.io/oss-fuzz-base/base-builder # Install OBS dependencies and ffmpeg build dependencies diff --git a/projects/obs-studio/build.sh b/projects/obs-studio/build.sh index 61dab5b6caa8..85a9d95f6ae2 100644 --- a/projects/obs-studio/build.sh +++ b/projects/obs-studio/build.sh @@ -1,3 +1,19 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + : ${LD:="${CXX}"} : ${LDFLAGS:="${CXXFLAGS}"} # to make sure we link with sanitizer runtime diff --git a/projects/obs-studio/fuzz_util_bitstream_reader.cpp b/projects/obs-studio/fuzz_util_bitstream_reader.cpp index 92072584a8fd..b8f28269212e 100644 --- a/projects/obs-studio/fuzz_util_bitstream_reader.cpp +++ b/projects/obs-studio/fuzz_util_bitstream_reader.cpp @@ -1,3 +1,15 @@ +/* Copyright 2025 Google LLC +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + #include #include From ddfe7f8d11d7aa105f78b2a1ee5a9510e0a05ef1 Mon Sep 17 00:00:00 2001 From: Marcello Maugeri Date: Sat, 28 Jun 2025 18:35:15 +0200 Subject: [PATCH 4/6] include apt-get update before --- projects/obs-studio/Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/projects/obs-studio/Dockerfile b/projects/obs-studio/Dockerfile index 9fa57149a072..fe2567fe3266 100644 --- a/projects/obs-studio/Dockerfile +++ b/projects/obs-studio/Dockerfile @@ -16,8 +16,10 @@ FROM gcr.io/oss-fuzz-base/base-builder +RUN apt-get update + # Install OBS dependencies and ffmpeg build dependencies -RUN apt-get update && apt-get install -y \ +RUN apt-get install -y \ # OBS dependencies libx264-dev libcurl4-openssl-dev libmbedtls-dev libgl1-mesa-dev libjansson-dev \ libluajit-5.1-dev python3-dev libx11-dev libxcb-randr0-dev libxcb-shm0-dev libxcb-xinerama0-dev \ From 10aa15ef2cb4acc065e9e47cb08a2afa0d8fa954 Mon Sep 17 00:00:00 2001 From: Marcello Maugeri Date: Mon, 30 Jun 2025 09:24:43 +0200 Subject: [PATCH 5/6] fix presubmit checks --- projects/obs-studio/Dockerfile | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/projects/obs-studio/Dockerfile b/projects/obs-studio/Dockerfile index fe2567fe3266..a34e461b78a5 100644 --- a/projects/obs-studio/Dockerfile +++ b/projects/obs-studio/Dockerfile @@ -15,11 +15,10 @@ ################################################################################ FROM gcr.io/oss-fuzz-base/base-builder - -RUN apt-get update + # Install OBS dependencies and ffmpeg build dependencies -RUN apt-get install -y \ +RUN apt-get update && apt-get install -y \ # OBS dependencies libx264-dev libcurl4-openssl-dev libmbedtls-dev libgl1-mesa-dev libjansson-dev \ libluajit-5.1-dev python3-dev libx11-dev libxcb-randr0-dev libxcb-shm0-dev libxcb-xinerama0-dev \ @@ -28,9 +27,8 @@ RUN apt-get install -y \ libpci-dev libqrcodegencpp-dev uthash-dev software-properties-common \ extra-cmake-modules uuid-dev libpulse-dev libdrm-dev \ # FFmpeg build dependencies - build-essential yasm nasm libvpx-dev libmp3lame-dev libopus-dev wget bzip2 + build-essential yasm nasm libvpx-dev libmp3lame-dev libopus-dev wget bzip2 pkg-config -RUN apt-get install -y pkg-config # Download, build, and install FFmpeg 6.1.1 RUN cd /tmp && \ wget https://ffmpeg.org/releases/ffmpeg-6.1.1.tar.bz2 && \ @@ -51,8 +49,7 @@ RUN cd /tmp && \ cd / && rm -rf /tmp/ffmpeg-6.1.1* RUN add-apt-repository ppa:okirby/qt6-backports -RUN apt update -RUN apt-get install -y qt6-tools-dev libqt6svg6-dev libqt6xml6 qt6-base-dev libqt6widgets6 nlohmann-json3-dev libqt6svg6 libxkbcommon-dev qt6-base-private-dev +RUN apt update && apt-get install -y qt6-tools-dev libqt6svg6-dev libqt6xml6 qt6-base-dev libqt6widgets6 nlohmann-json3-dev libqt6svg6 libxkbcommon-dev qt6-base-private-dev # Clone OBS Studio and set up for the build RUN git clone --recursive https://github.com/obsproject/obs-studio.git obs-studio From 1b3690c896215f556393b98475d2f35e701ac41a Mon Sep 17 00:00:00 2001 From: Marcello Maugeri Date: Wed, 9 Jul 2025 20:38:36 +0200 Subject: [PATCH 6/6] Add primary_contact to project.yaml --- projects/obs-studio/project.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/obs-studio/project.yaml b/projects/obs-studio/project.yaml index df58247fe8b3..0040e48518ab 100644 --- a/projects/obs-studio/project.yaml +++ b/projects/obs-studio/project.yaml @@ -1,6 +1,6 @@ homepage: "https://obsproject.com/" language: c -primary_contact: "todo@mail.com" +primary_contact: "joel.bethke@gmail.com" sanitizers: - address - undefined