From 8a893ac72ef138ae4adb22b7ee70aa189a808a4d Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Wed, 20 Dec 2023 20:41:52 +0100
Subject: [PATCH] main/freeswitch: security upgrade to 1.10.10

- CVE-2023-40018
- CVE-2023-40019

ref: https://github.com/signalwire/freeswitch/releases/tag/v1.10.10
(cherry picked from commit b6b8c5c7746e984f08dd8a66bed2d7ae238a8f0d)
(cherry picked from commit 5745c542925397f583bdec3d859e87691f4d52ac)
(cherry picked from commit 958d24054f7813af48a369c4c9984d45d9572857)
(cherry picked from commit 10030b4102873f634899f3fdb4b37115d6f7c30e)
---
 main/freeswitch/APKBUILD                      | 15 ++----
 main/freeswitch/configure-lua53.patch         | 21 --------
 main/freeswitch/explicit-darwin-macro.patch   | 15 ------
 .../fix-undeclared-function-s390x.patch       | 21 --------
 main/freeswitch/include-lua53.patch           | 48 -------------------
 5 files changed, 4 insertions(+), 116 deletions(-)
 delete mode 100644 main/freeswitch/configure-lua53.patch
 delete mode 100644 main/freeswitch/explicit-darwin-macro.patch
 delete mode 100644 main/freeswitch/fix-undeclared-function-s390x.patch
 delete mode 100644 main/freeswitch/include-lua53.patch

diff --git a/main/freeswitch/APKBUILD b/main/freeswitch/APKBUILD
index 74da9e7b62aa..d84def16d808 100644
--- a/main/freeswitch/APKBUILD
+++ b/main/freeswitch/APKBUILD
@@ -3,8 +3,8 @@
 # Contributor: Cameron Banta <cbanta@gmail.com>
 # Contributor: Francesco Colista <fcolista@alpinelinux.org>
 pkgname=freeswitch
-pkgver=1.10.7
-pkgrel=2
+pkgver=1.10.10
+pkgrel=0
 pkgdesc="A communications platform written in C from the ground up"
 url="https://www.freeswitch.org/"
 arch="all"
@@ -65,13 +65,9 @@ subpackages="$pkgname-static $pkgname-dev $pkgname-flite $pkgname-timezones::noa
 	$pkgname-openrc $pkgname-dbg"
 
 source="https://files.freeswitch.org/freeswitch-releases/freeswitch-$pkgver.-release.tar.xz
-	configure-lua53.patch
-	include-lua53.patch
 	getlib.patch
 	libvpx-fix-arm-float-abi.patch
 	disable-Werror.patch
-	explicit-darwin-macro.patch
-	fix-undeclared-function-s390x.patch
 	python-3.10.patch
 	modules.conf
 	freeswitch.confd
@@ -111,6 +107,7 @@ build() {
 		--with-python3 \
 		--disable-debug \
 		--enable-core-pgsql-support \
+		--enable-static \
 		--enable-system-lua \
 		--enable-system-xmlrpc-c
 
@@ -225,14 +222,10 @@ conf() {
 }
 
 sha512sums="
-9c0b29f8e631c5e7d073cb2a70c53ffb16780029e462e6171651a54d9f2a2c73f6c871c8bea9e7715ddb40cd7005d73c5931e6a8af33eeb5a01aa7c8a83dda5b  freeswitch-1.10.7.-release.tar.xz
-222e3510790de29e29428c70325eb1d4e7852eb4315ee546f137293868bd71acf89e7c85c5ca9d0eb708090c9eef91878a8e12c1b9d5cc99a68fecbd42ad962f  configure-lua53.patch
-c1960f3c7acf729468b819f7f15d66a251c3967b2784bce18c7755b333156e687c55fdc1aceda588ceb1bf9638e2fd4a31a169b00b15c5040cf1001c3c73913b  include-lua53.patch
+b43079bc818a86bf667d9b328cf904e49c8455827c199c832ee686ff8634273ea186c35d907bed19d0474cbc2e1232d81624ae878a9aaa3b8897fd76e9916e55  freeswitch-1.10.10.-release.tar.xz
 4ceb48f64d2bc26a02cc0846276506241bfd30c156422b0a1d608fd172c099feb5c121a763652e9a45046dcdd0ba0eb71eab240e0c6ce2ad63ff781719e135a4  getlib.patch
 98a53f289c3647cafd05b6f847da0504a838a6e06545c133c10fb058c2d941e6bccf2820f44649fc25f94a4a5b7c1280eaee91098e8110f96ed3342c1cb4346c  libvpx-fix-arm-float-abi.patch
 16e9208fca7f0a1985dd01ec38ddabb6a79da83ad6ab004bb66de528ac45f02fadaddc50a9f228e1aa38fae213fa5af0ca858b7af629b67a7d654339f813a68c  disable-Werror.patch
-7c2fa472a3abb5d735902e9a8f1fc6e9c9053955d453216313dd47a263af290cf1f3a92d7297a380e9bbaa17fddc1aacd55c8a72228d2335a9a7bf4ef01aef6c  explicit-darwin-macro.patch
-d91350af634d3e6fd6a460d3b861ab0e7289c206d3200bcd7cb5ef9536df1ac9181f7e84462132c5bc8d72329e2e8683aa99ab399fd58324cd85f0280b424874  fix-undeclared-function-s390x.patch
 4739be0c1c6783ace2bd10f7573b1ca86be013d21a7f973b5fd348c98fb9ed1a548baacee6bb65b7501251106c8dbd7266997f8699d2d7070a2bd7efe145b866  python-3.10.patch
 e495f955bdfd89259d8c907a7159e15bf17bd5933b0a643fba08f022583b518758b2a6ff301b79a24c099352bb39d4724f779dfc76eb924c103d2cb160fc2aa9  modules.conf
 a585f6411185a26206137a1ad97a06fd6c73e80c5439e9be45eabfa70e7a83120169ba882971fcd328436c8e0242cbd664170b80754ea2846021689baf1f1595  freeswitch.confd
diff --git a/main/freeswitch/configure-lua53.patch b/main/freeswitch/configure-lua53.patch
deleted file mode 100644
index d78f7e8c20b6..000000000000
--- a/main/freeswitch/configure-lua53.patch
+++ /dev/null
@@ -1,21 +0,0 @@
-diff --git a/configure.ac b/configure.ac
-index 127ee01..1b2c041 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -593,14 +593,14 @@ AC_SUBST(SYS_XMLRPC_CFLAGS)
- AC_SUBST(SYS_XMLRPC_LDFLAGS)
- AM_CONDITIONAL([SYSTEM_XMLRPCC],[test "${enable_xmlrpcc}" = "yes"])
- 
--for luaversion in luajit lua5.2 lua-5.2 lua52 lua5.1 lua-5.1 lua; do
-+for luaversion in lua5.3 lua-5.3 lua53 lua5.2 lua-5.2 lua52 lua5.1 lua-5.1 lua; do
-   PKG_CHECK_MODULES([LUA],[${luaversion}],[have_lua=yes],[have_lua=no])
-   if test ${have_lua} = yes; then
-     break
-   fi
- done
- if test x"${LUA_LIBS}" = x"" ; then
--   LUA_LIBS="-llua"
-+   LUA_LIBS="-llua5.3"
- fi
- 
- AC_ARG_ENABLE(srtp,
diff --git a/main/freeswitch/explicit-darwin-macro.patch b/main/freeswitch/explicit-darwin-macro.patch
deleted file mode 100644
index 7da441c4d521..000000000000
--- a/main/freeswitch/explicit-darwin-macro.patch
+++ /dev/null
@@ -1,15 +0,0 @@
-diff --git a/libs/apr/include/apr_general.h b/libs/apr/include/apr_general.h
-index 3a95628..42eec83 100644
---- a/libs/apr/include/apr_general.h
-+++ b/libs/apr/include/apr_general.h
-@@ -29,10 +29,6 @@
- #include "apr_pools.h"
- #include "apr_errno.h"
-
--#if !defined(_ANSI_SOURCE) && defined(_DARWIN_C_SOURCE)
--#define NSIG __DARWIN_NSIG
--#endif
--
- #if APR_HAVE_SIGNAL_H
- #include <signal.h>
- #endif
diff --git a/main/freeswitch/fix-undeclared-function-s390x.patch b/main/freeswitch/fix-undeclared-function-s390x.patch
deleted file mode 100644
index b04672a203c4..000000000000
--- a/main/freeswitch/fix-undeclared-function-s390x.patch
+++ /dev/null
@@ -1,21 +0,0 @@
-From 68039d344d8e826e8b403c9cd0284fd07b4495ac Mon Sep 17 00:00:00 2001
-From: Dragos Oancea <dragos@signalwire.com>
-Date: Tue, 26 Oct 2021 08:42:58 +0000
-Subject: [PATCH] [core] fix build SWITCH_BYTE_ORDER == __BIG_ENDIAN
-
----
- src/switch_rtp.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-index 1880bbb..843ee81 100644
---- a/src/switch_rtp.c
-+++ b/src/switch_rtp.c
-@@ -2155,7 +2155,7 @@ static void switch_send_rtcp_event(switch_rtp_t *rtp_session ,struct switch_rtcp
- 				switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header, value);
- 				snprintf(header, sizeof(header), "Source-Lost");
- #if SWITCH_BYTE_ORDER == __BIG_ENDIAN
--				tmpLost = report->lost; /* signed 24bit will extended signess to int32_t automatically */
-+				tmpLost = rtcp_report_block->lost; /* signed 24bit will extended signess to int32_t automatically */
- #else
- 				tmpLost = ntohl(rtcp_report_block->lost)>>8;
- 				tmpLost = tmpLost | ((tmpLost & 0x00800000) ? 0xff000000 : 0x00000000); /* ...and signess compensation */
diff --git a/main/freeswitch/include-lua53.patch b/main/freeswitch/include-lua53.patch
deleted file mode 100644
index 859077598150..000000000000
--- a/main/freeswitch/include-lua53.patch
+++ /dev/null
@@ -1,48 +0,0 @@
-diff --git a/src/mod/languages/mod_lua/mod_lua.cpp b/src/mod/languages/mod_lua/mod_lua.cpp
-index 63aaf25..1b37b77 100644
---- a/src/mod/languages/mod_lua/mod_lua.cpp
-+++ b/src/mod/languages/mod_lua/mod_lua.cpp
-@@ -34,9 +34,9 @@
- #include <switch.h>
- #include <switch_event.h>
- SWITCH_BEGIN_EXTERN_C
--#include "lua.h"
--#include <lauxlib.h>
--#include <lualib.h>
-+#include "lua5.3/lua.h"
-+#include <lua5.3/lauxlib.h>
-+#include <lua5.3/lualib.h>
- #include "mod_lua_extra.h"
- SWITCH_MODULE_LOAD_FUNCTION(mod_lua_load);
- SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_lua_shutdown);
-diff --git a/src/mod/languages/mod_lua/freeswitch_lua.h b/src/mod/languages/mod_lua/freeswitch_lua.h
-index d205f6b..f34bd84 100644
---- a/src/mod/languages/mod_lua/freeswitch_lua.h
-+++ b/src/mod/languages/mod_lua/freeswitch_lua.h
-@@ -2,9 +2,9 @@
- #define FREESWITCH_LUA_H
- 
- extern "C" {
--#include "lua.h"
--#include <lauxlib.h>
--#include <lualib.h>
-+#include "lua5.3/lua.h"
-+#include <lua5.3/lauxlib.h>
-+#include <lua5.3/lualib.h>
- #include "mod_lua_extra.h"
- }
- #include <switch_cpp.h>
-diff --git a/libs/esl/lua/esl_wrap.cpp b/libs/esl/lua/esl_wrap.cpp
-index d89b83e..261eb97 100644
---- a/libs/esl/lua/esl_wrap.cpp
-+++ b/libs/esl/lua/esl_wrap.cpp
-@@ -730,8 +730,8 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
- extern "C" {
- #endif
- 
--#include "lua.h"
--#include "lauxlib.h"
-+#include "lua5.3/lua.h"
-+#include "lua5.3/lauxlib.h"
- #include <stdlib.h>  /* for malloc */
- #include <assert.h>  /* for a few sanity tests */
-- 
GitLab