From ceec1584a99367229b7249ce6bfcbeb8a39f1dea Mon Sep 17 00:00:00 2001 From: Tad Date: Fri, 18 Aug 2023 11:17:13 -0400 Subject: [PATCH] Fixup hosts cache thanks to patch from @danielk43 Closes https://github.com/Divested-Mobile/DivestOS-Build/issues/198 Signed-off-by: Tad --- .../0003-Reuse-align_ptr-in-hosts_cache.patch | 34 +++++++++++++++++++ .../0003-Reuse-align_ptr-in-hosts_cache.patch | 34 +++++++++++++++++++ .../0003-Reuse-align_ptr-in-hosts_cache.patch | 34 +++++++++++++++++++ Scripts/LineageOS-18.1/Patch.sh | 1 + Scripts/LineageOS-19.1/Patch.sh | 1 + Scripts/LineageOS-20.0/Patch.sh | 1 + 6 files changed, 105 insertions(+) create mode 100644 Patches/LineageOS-18.1/android_packages_modules_DnsResolver/0003-Reuse-align_ptr-in-hosts_cache.patch create mode 100644 Patches/LineageOS-19.1/android_packages_modules_DnsResolver/0003-Reuse-align_ptr-in-hosts_cache.patch create mode 100644 Patches/LineageOS-20.0/android_packages_modules_DnsResolver/0003-Reuse-align_ptr-in-hosts_cache.patch diff --git a/Patches/LineageOS-18.1/android_packages_modules_DnsResolver/0003-Reuse-align_ptr-in-hosts_cache.patch b/Patches/LineageOS-18.1/android_packages_modules_DnsResolver/0003-Reuse-align_ptr-in-hosts_cache.patch new file mode 100644 index 00000000..97501128 --- /dev/null +++ b/Patches/LineageOS-18.1/android_packages_modules_DnsResolver/0003-Reuse-align_ptr-in-hosts_cache.patch @@ -0,0 +1,34 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: danielk43 <11856117+danielk43@users.noreply.github.com> +Date: Sun, 26 Mar 2023 11:37:26 -0400 +Subject: [PATCH] Reuse align_ptr in hosts_cache + +Change-Id: I461718c38ca3c0e372e1cc0e0f0deb74ae5c68bb +--- + hosts_cache.cpp | 6 +----- + 1 file changed, 1 insertion(+), 5 deletions(-) + +diff --git a/hosts_cache.cpp b/hosts_cache.cpp +index 258eac1b..be8a0ff4 100644 +--- a/hosts_cache.cpp ++++ b/hosts_cache.cpp +@@ -47,10 +47,6 @@ constexpr int MAXADDRS = 35; + #define ESTIMATED_LINELEN 32 + #define HCFILE_ALLOC_SIZE 256 + +-/* From sethostent.c */ +-#define ALIGNBYTES (sizeof(uintptr_t) - 1) +-#define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) &~ ALIGNBYTES) +- + /* + * Host cache entry for hcfile.c_data. + * Offsets are into hcfile.h_data. +@@ -500,7 +496,7 @@ int hc_gethtbyname(const char *host, int af, struct getnamaddr *info) + if (naliases >= MAXALIASES) + goto nospc; + } +- aligned = (char *)ALIGN(info->buf); ++ aligned = align_ptr(info->buf); + if (info->buf != aligned) { + if ((ptrdiff_t)info->buflen < (aligned - info->buf)) + goto nospc; diff --git a/Patches/LineageOS-19.1/android_packages_modules_DnsResolver/0003-Reuse-align_ptr-in-hosts_cache.patch b/Patches/LineageOS-19.1/android_packages_modules_DnsResolver/0003-Reuse-align_ptr-in-hosts_cache.patch new file mode 100644 index 00000000..97501128 --- /dev/null +++ b/Patches/LineageOS-19.1/android_packages_modules_DnsResolver/0003-Reuse-align_ptr-in-hosts_cache.patch @@ -0,0 +1,34 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: danielk43 <11856117+danielk43@users.noreply.github.com> +Date: Sun, 26 Mar 2023 11:37:26 -0400 +Subject: [PATCH] Reuse align_ptr in hosts_cache + +Change-Id: I461718c38ca3c0e372e1cc0e0f0deb74ae5c68bb +--- + hosts_cache.cpp | 6 +----- + 1 file changed, 1 insertion(+), 5 deletions(-) + +diff --git a/hosts_cache.cpp b/hosts_cache.cpp +index 258eac1b..be8a0ff4 100644 +--- a/hosts_cache.cpp ++++ b/hosts_cache.cpp +@@ -47,10 +47,6 @@ constexpr int MAXADDRS = 35; + #define ESTIMATED_LINELEN 32 + #define HCFILE_ALLOC_SIZE 256 + +-/* From sethostent.c */ +-#define ALIGNBYTES (sizeof(uintptr_t) - 1) +-#define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) &~ ALIGNBYTES) +- + /* + * Host cache entry for hcfile.c_data. + * Offsets are into hcfile.h_data. +@@ -500,7 +496,7 @@ int hc_gethtbyname(const char *host, int af, struct getnamaddr *info) + if (naliases >= MAXALIASES) + goto nospc; + } +- aligned = (char *)ALIGN(info->buf); ++ aligned = align_ptr(info->buf); + if (info->buf != aligned) { + if ((ptrdiff_t)info->buflen < (aligned - info->buf)) + goto nospc; diff --git a/Patches/LineageOS-20.0/android_packages_modules_DnsResolver/0003-Reuse-align_ptr-in-hosts_cache.patch b/Patches/LineageOS-20.0/android_packages_modules_DnsResolver/0003-Reuse-align_ptr-in-hosts_cache.patch new file mode 100644 index 00000000..97501128 --- /dev/null +++ b/Patches/LineageOS-20.0/android_packages_modules_DnsResolver/0003-Reuse-align_ptr-in-hosts_cache.patch @@ -0,0 +1,34 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: danielk43 <11856117+danielk43@users.noreply.github.com> +Date: Sun, 26 Mar 2023 11:37:26 -0400 +Subject: [PATCH] Reuse align_ptr in hosts_cache + +Change-Id: I461718c38ca3c0e372e1cc0e0f0deb74ae5c68bb +--- + hosts_cache.cpp | 6 +----- + 1 file changed, 1 insertion(+), 5 deletions(-) + +diff --git a/hosts_cache.cpp b/hosts_cache.cpp +index 258eac1b..be8a0ff4 100644 +--- a/hosts_cache.cpp ++++ b/hosts_cache.cpp +@@ -47,10 +47,6 @@ constexpr int MAXADDRS = 35; + #define ESTIMATED_LINELEN 32 + #define HCFILE_ALLOC_SIZE 256 + +-/* From sethostent.c */ +-#define ALIGNBYTES (sizeof(uintptr_t) - 1) +-#define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) &~ ALIGNBYTES) +- + /* + * Host cache entry for hcfile.c_data. + * Offsets are into hcfile.h_data. +@@ -500,7 +496,7 @@ int hc_gethtbyname(const char *host, int af, struct getnamaddr *info) + if (naliases >= MAXALIASES) + goto nospc; + } +- aligned = (char *)ALIGN(info->buf); ++ aligned = align_ptr(info->buf); + if (info->buf != aligned) { + if ((ptrdiff_t)info->buflen < (aligned - info->buf)) + goto nospc; diff --git a/Scripts/LineageOS-18.1/Patch.sh b/Scripts/LineageOS-18.1/Patch.sh index 9bcadf46..78a3ea8a 100644 --- a/Scripts/LineageOS-18.1/Patch.sh +++ b/Scripts/LineageOS-18.1/Patch.sh @@ -356,6 +356,7 @@ applyPatch "$DOS_PATCHES_COMMON/android_packages_inputmethods_LatinIME/0002-Disa fi; if enterAndClear "packages/modules/DnsResolver"; then +applyPatch "$DOS_PATCHES/android_packages_modules_DnsResolver/0003-Reuse-align_ptr-in-hosts_cache.patch"; #Reuse align_ptr in hosts_cache (danielk43) applyPatch "$DOS_PATCHES/android_packages_modules_DnsResolver/0001-hosts_toggle.patch"; #Add a toggle to disable /etc/hosts lookup (DivestOS) fi; diff --git a/Scripts/LineageOS-19.1/Patch.sh b/Scripts/LineageOS-19.1/Patch.sh index 361f8ad6..7dcb1ba5 100644 --- a/Scripts/LineageOS-19.1/Patch.sh +++ b/Scripts/LineageOS-19.1/Patch.sh @@ -345,6 +345,7 @@ if enterAndClear "packages/modules/DnsResolver"; then applyPatch "$DOS_PATCHES/android_packages_modules_DnsResolver/0001-Hosts_Cache.patch"; #DnsResolver: Sort and cache hosts file data for fast lookup (tdm) applyPatch "$DOS_PATCHES/android_packages_modules_DnsResolver/0001-Hosts_Wildcards.patch"; #DnsResolver: Support wildcards in cached hosts file (tdm) applyPatch "$DOS_PATCHES/android_packages_modules_DnsResolver/0002-hosts_toggle.patch"; #Add a toggle to disable /etc/hosts lookup (DivestOS) +applyPatch "$DOS_PATCHES/android_packages_modules_DnsResolver/0003-Reuse-align_ptr-in-hosts_cache.patch"; #Reuse align_ptr in hosts_cache (danielk43) fi; if enterAndClear "packages/modules/NetworkStack"; then diff --git a/Scripts/LineageOS-20.0/Patch.sh b/Scripts/LineageOS-20.0/Patch.sh index 045cd67e..361f8611 100644 --- a/Scripts/LineageOS-20.0/Patch.sh +++ b/Scripts/LineageOS-20.0/Patch.sh @@ -346,6 +346,7 @@ if enterAndClear "packages/modules/DnsResolver"; then applyPatch "$DOS_PATCHES/android_packages_modules_DnsResolver/0001-Hosts_Cache.patch"; #DnsResolver: Sort and cache hosts file data for fast lookup (tdm) applyPatch "$DOS_PATCHES/android_packages_modules_DnsResolver/0001-Hosts_Wildcards.patch"; #DnsResolver: Support wildcards in cached hosts file (tdm) applyPatch "$DOS_PATCHES/android_packages_modules_DnsResolver/0002-hosts_toggle.patch"; #Add a toggle to disable /etc/hosts lookup (DivestOS) +applyPatch "$DOS_PATCHES/android_packages_modules_DnsResolver/0003-Reuse-align_ptr-in-hosts_cache.patch"; #Reuse align_ptr in hosts_cache (danielk43) #applyPatch "$DOS_PATCHES/android_packages_modules_DnsResolver/0004-More-DoH.patch"; #Add more DoH endpoints (DivestOS) fi;