- Add 2635.patch: this fixes and issue on i586 and x86

OBS-URL: https://build.opensuse.org/package/show/multimedia:apps/gerbera?expand=0&rev=35
This commit is contained in:
Paolo Stivanin 2022-05-18 09:23:58 +00:00 committed by Git OBS Bridge
parent 2230b7512a
commit 1c0807ae8a
3 changed files with 130 additions and 0 deletions

123
2635.patch Normal file
View File

@ -0,0 +1,123 @@
From 9e763df4e7be2e73c9b84001d85d0be8d8bb741c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Karl=20Strau=C3=9Fberger?= <k_straussberger@netzland.net>
Date: Tue, 17 May 2022 18:13:55 +0200
Subject: [PATCH] This and that
May even solve:
---
src/metadata/resolution.cc | 4 ++--
src/upnp_xml.cc | 4 ++--
src/util/process_executor.cc | 3 ++-
src/util/tools.cc | 14 ++++++++++++--
test/content/test_resolution.cc | 6 +++---
5 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/src/metadata/resolution.cc b/src/metadata/resolution.cc
index 031cb5788..476c644e5 100644
--- a/src/metadata/resolution.cc
+++ b/src/metadata/resolution.cc
@@ -33,7 +33,7 @@ Resolution::Resolution(const std::string& string)
if (!parts[0].empty()) {
auto x = stoulString(trimString(parts[0]));
- if (x == 0 || x == std::numeric_limits<unsigned int>::max()) {
+ if (x == 0 || x == std::numeric_limits<uint64_t>::max()) {
throw_std_runtime_error("Failed to parse '{}' to valid resolution", string);
}
_x = x;
@@ -41,7 +41,7 @@ Resolution::Resolution(const std::string& string)
if (!parts[1].empty()) {
auto y = stoulString(trimString(parts[1]));
- if (y == 0 || y == std::numeric_limits<unsigned int>::max()) {
+ if (y == 0 || y == std::numeric_limits<uint64_t>::max()) {
throw_std_runtime_error("Failed to parse '{}' to valid resolution", string);
}
_y = y;
diff --git a/src/upnp_xml.cc b/src/upnp_xml.cc
index d2d6bc60b..2ed9c7bef 100644
--- a/src/upnp_xml.cc
+++ b/src/upnp_xml.cc
@@ -508,9 +508,9 @@ std::string UpnpXMLBuilder::renderExtension(const std::string& contentType, cons
}
if (!location.empty() && location.has_extension()) {
- std::string extension = location.filename().extension();
+ std::string extension = urlEscape(location.filename().extension().string());
if (!language.empty())
- return fmt::format("{}.{}{}", urlExt, language, extension);
+ return fmt::format("{}.{}{}", urlExt, urlEscape(language), extension);
return fmt::format("{}{}", urlExt, extension);
}
diff --git a/src/util/process_executor.cc b/src/util/process_executor.cc
index 5f238058a..8557175fe 100644
--- a/src/util/process_executor.cc
+++ b/src/util/process_executor.cc
@@ -70,7 +70,8 @@ ProcessExecutor::ProcessExecutor(const std::string& command, const std::vector<s
log_debug("setenv: {}='{}'", eName, eValue);
}
log_debug("Launching process: {} {}", command, fmt::join(arglist, " "));
- execvp(command.c_str(), const_cast<char**>(argv.data()));
+ if (execvp(command.c_str(), const_cast<char**>(argv.data())))
+ log_error("Failed to execvp {} {}", command, fmt::join(arglist, " "));
break;
default:
break;
diff --git a/src/util/tools.cc b/src/util/tools.cc
index 119b74f5b..c549744be 100644
--- a/src/util/tools.cc
+++ b/src/util/tools.cc
@@ -118,7 +118,17 @@ unsigned long stoulString(const std::string& str, int def, int base)
if (str.empty() || (str[0] == '-' && !std::isdigit(*str.substr(1).c_str())) || (str[0] != '-' && !std::isdigit(*str.c_str())))
return def;
- return std::stoul(str, nullptr, base);
+ try {
+ std::size_t pos;
+ return std::stoul(str, &pos, base);
+ } catch (const std::invalid_argument& iaex) {
+ log_error("ia {} (input {})", iaex.what(), str);
+ } catch (const std::out_of_range& oorex) {
+ log_error("oor {} (input {})", oorex.what(), str);
+ } catch (const std::exception& ex) {
+ log_error("{} (input {})", ex.what(), str);
+ }
+ return def;
}
void reduceString(std::string& str, char ch)
@@ -252,7 +262,7 @@ std::string urlEscape(std::string_view str)
if ((i + cplen) > str.length())
cplen = 1;
- if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '_' || c == '-') {
+ if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '_' || c == '-' || c == '.') {
buf << char(c);
} else {
int hi = c >> 4;
diff --git a/test/content/test_resolution.cc b/test/content/test_resolution.cc
index 6d4a75610..c30c5c489 100644
--- a/test/content/test_resolution.cc
+++ b/test/content/test_resolution.cc
@@ -3,10 +3,10 @@
#include "metadata//resolution.h"
TEST(ResolutionTest, parse) {
- auto res = Resolution("122586668x54589448448485");
+ auto res = Resolution("122586668x448448485");
EXPECT_EQ(res.x(), 122586668);
- EXPECT_EQ(res.y(), 54589448448485);
+ EXPECT_EQ(res.y(), 448448485);
}
TEST(ResolutionTest, parseWithSpace) {
@@ -38,4 +38,4 @@ TEST(ResolutionTest, throwOnBad) {
EXPECT_THROW(Resolution("0x"), std::runtime_error);
EXPECT_THROW(Resolution("0x1"), std::runtime_error);
EXPECT_THROW(Resolution("1x0"), std::runtime_error);
-}
\ No newline at end of file
+}

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Wed May 18 09:23:12 UTC 2022 - Paolo Stivanin <info@paolostivanin.com>
- Add 2635.patch: this fixes and issue on i586 and x86
-------------------------------------------------------------------
Tue May 17 18:43:32 UTC 2022 - Paolo Stivanin <info@paolostivanin.com>

View File

@ -27,6 +27,8 @@ Source0: https://github.com/gerbera/gerbera/archive/v%{version}.tar.gz#/%
Source1: config.xml
Source2: gerbera.sysusers.in
Patch0: harden_gerbera.service.patch
#PATCH-FIX-UPSTREAM https://github.com/gerbera/gerbera/pull/2635
Patch1: 2635.patch
BuildRequires: ccache
BuildRequires: cmake >= 3.13
BuildRequires: fdupes