From b9ff168444c2b25a39e1221a707f88c3e658e941 Mon Sep 17 00:00:00 2001
From: akwizgran <michael@briarproject.org>
Date: Thu, 7 Dec 2023 14:34:45 +0000
Subject: [PATCH] Raise min Android API level to 18 to enable hardening.

-D_FORTIFY_SOURCE=2 has no effect with the API 16 compiler,
which resulted in our 32-bit binaries not having those
protections.
---
 build_tor_android.py | 4 ----
 tor-build/Makefile   | 5 +++--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/build_tor_android.py b/build_tor_android.py
index 8f16b24..b0c7e95 100755
--- a/build_tor_android.py
+++ b/build_tor_android.py
@@ -64,28 +64,24 @@ def build_android(versions):
     app_abi = 'armeabi-v7a'
     env = os.environ.copy()
     env['APP_ABI'] = app_abi
-    env['NDK_PLATFORM_LEVEL'] = "16"  # first level supporting PIE
     build_android_arch(app_abi, env, versions)
 
     # build arm64 pie
     app_abi = 'arm64-v8a'
     env = os.environ.copy()
     env['APP_ABI'] = app_abi
-    env['NDK_PLATFORM_LEVEL'] = "21"  # first level supporting 64-bit
     build_android_arch(app_abi, env, versions)
 
     # build x86 pie
     app_abi = 'x86'
     env = os.environ.copy()
     env['APP_ABI'] = app_abi
-    env['NDK_PLATFORM_LEVEL'] = "16"  # first level supporting PIE
     build_android_arch(app_abi, env, versions)
 
     # build x86_64 pie
     app_abi = 'x86_64'
     env = os.environ.copy()
     env['APP_ABI'] = app_abi
-    env['NDK_PLATFORM_LEVEL'] = "21"  # first level supporting 64-bit
     build_android_arch(app_abi, env, versions)
 
 
diff --git a/tor-build/Makefile b/tor-build/Makefile
index 62952a0..d87f71b 100644
--- a/tor-build/Makefile
+++ b/tor-build/Makefile
@@ -49,7 +49,7 @@ ifneq ($(filter armeabi-v7a, $(APP_ABI)),)
  GREP_CHECK := EABI5
  NDK_ABI := arm
  NDK_BIT := 32
- NDK_PLATFORM_LEVEL := 16
+ NDK_PLATFORM_LEVEL := 18
  NDK_TOOLCHAIN := $(HOST)-$(NDK_TOOLCHAIN_VERSION)
 endif
 ifneq ($(filter x86, $(APP_ABI)),)
@@ -58,7 +58,7 @@ ifneq ($(filter x86, $(APP_ABI)),)
  GREP_CHECK := 80386
  NDK_ABI := x86
  NDK_BIT := 32
- NDK_PLATFORM_LEVEL := 16
+ NDK_PLATFORM_LEVEL := 18
  NDK_TOOLCHAIN := $(NDK_ABI)-$(NDK_TOOLCHAIN_VERSION)
 endif
 ifneq ($(filter x86_64, $(APP_ABI)),)
@@ -221,6 +221,7 @@ tor/Makefile: tor/configure.ac tor/Makefile.am
 	cd tor && \
 			./configure \
 				--host=$(ALTHOST) \
+				--enable-android \
 				--enable-lzma \
 				--enable-pic \
 				--enable-static-libevent --with-libevent-dir=$(EXTERNAL_ROOT) \
-- 
GitLab