package/android-tools: fix b64_pton() issue with GCC >= 14.x

The android-tools code base uses the __b64_pton() function, which
isn't provided by all C libraries. So the Debian patch
debian/patches/add_adbd.patch adds an implementation of b64_pton(),
but doesn't actually use it, nor defines a prototype for it. Our
existing patch 0003-Fix-build-issue-with-uclibc.patch switches the
code to use the b64_pton() function... but still without providing a
prototype, causing the following build failures with GCC >= 14.x:

adb_auth_client.c:75:15: error: implicit declaration of function 'b64_pton'

To fix this, we rework 0003-Fix-build-issue-with-uclibc.patch into a
patch that:

 (1) Renames b64_pton() to adb_b64_pton() to make sure it won't clash
     with implementations provided by some C libraries, and adjusts
     the call sites accordingly.

 (2) Adds a prototype definition of adb_b64_pton() in places where
     this function is used.

Fixes:

  http://autobuild.buildroot.net/results/b25b25337c7ad89c33f8bd20b646850bd993ec53ae9/

Even though GCC 14.x support was merged in Buildroot in May 2024, this
particular b64_pton() only started appearing on July 15 2024, with the
first occurrence being:

  http://autobuild.buildroot.net/results/1cbe87bbe3c56f28444b3aaba1ba1d05f947d36e/

Indeed, it's not before July 15 2024 that we merged commit
d201f2f5cd0d1e0389430cda78adead37977a6cd ("package/android-tools: add
patches to fix build with GCC 14.x"), which fixed other GCC 14.x
issues, which were hiding this b64_pton() problem.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
(cherry picked from commit 1eec67d164c7087aa0bed30599681e908fb2fb41)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
This commit is contained in:
Thomas Petazzoni 2024-12-04 21:48:02 +01:00 committed by Peter Korsgaard
parent b8e9a352d2
commit fa11dff848
3 changed files with 96 additions and 41 deletions

View File

@ -131,7 +131,6 @@ package/am33x-cm3/0004-Makefile-add-fno-builtin.patch Upstream
package/am33x-cm3/S93-am335x-pm-firmware-load Variables
package/android-tools/0001-Fix-makefiles-for-out-of-tree-build.patch Upstream
package/android-tools/0002-Fix-adbd-for-non-Ubuntu-systems.patch Upstream
package/android-tools/0003-Fix-build-issue-with-uclibc.patch Upstream
package/android-tools/0004-Fix-build-issue-with-musl.patch Upstream
package/android-tools/0005-makefiles-use-pkgconf-to-get-libs-deps.patch Upstream
package/android-tools/0006-Fix-build-on-big-endian-systems.patch Upstream

View File

@ -0,0 +1,96 @@
From 946dbb00fe4b2a75c688a470fc0c3924aa018a24 Mon Sep 17 00:00:00 2001
From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Date: Sun, 14 Jul 2024 11:39:49 +0200
Subject: [PATCH] Adjust base64 function handling
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
In order to support libcs that do not provide b64_pton(), one of the
Debian patches adds a copy of b64_pton() and b64_ntop(). However, no
prototype is added for those functions, causing an "implicit
declaration" warning... or error depending on the compiler version
used:
core/adbd/adb_auth_client.c:75:15: error: implicit declaration of function b64_pton [-Wimplicit-function-declaration]
This patch adds appropriate prototypes, but while at it, also renames
the internal copy of b64_*() functions to have an adb_ prefix in order
to clarify things and not clash with definitions potentially coming
from the C library.
Upstream: N/A, we're too far from upstream
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
core/adb/adb_auth_client.c | 3 ++-
core/adbd/adb_auth_client.c | 3 ++-
core/adbd/base64.c | 4 ++--
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/core/adb/adb_auth_client.c b/core/adb/adb_auth_client.c
index 0b4913e..25b9828 100644
--- a/core/adb/adb_auth_client.c
+++ b/core/adb/adb_auth_client.c
@@ -45,6 +45,7 @@ static char *key_paths[] = {
static fdevent listener_fde;
static int framework_fd = -1;
+extern int adb_b64_pton(char const *src, u_char *target, size_t targsize);
static void read_keys(const char *file, struct listnode *list)
{
@@ -72,7 +73,7 @@ static void read_keys(const char *file, struct listnode *list)
if (sep)
*sep = '\0';
- ret = __b64_pton(buf, (u_char *)&key->key, sizeof(key->key) + 4);
+ ret = adb_b64_pton(buf, (u_char *)&key->key, sizeof(key->key) + 4);
if (ret != sizeof(key->key)) {
D("%s: Invalid base64 data ret=%d\n", file, ret);
free(key);
diff --git a/core/adbd/adb_auth_client.c b/core/adbd/adb_auth_client.c
index 0b4913e..25b9828 100644
--- a/core/adbd/adb_auth_client.c
+++ b/core/adbd/adb_auth_client.c
@@ -45,6 +45,7 @@ static char *key_paths[] = {
static fdevent listener_fde;
static int framework_fd = -1;
+extern int adb_b64_pton(char const *src, u_char *target, size_t targsize);
static void read_keys(const char *file, struct listnode *list)
{
@@ -72,7 +73,7 @@ static void read_keys(const char *file, struct listnode *list)
if (sep)
*sep = '\0';
- ret = __b64_pton(buf, (u_char *)&key->key, sizeof(key->key) + 4);
+ ret = adb_b64_pton(buf, (u_char *)&key->key, sizeof(key->key) + 4);
if (ret != sizeof(key->key)) {
D("%s: Invalid base64 data ret=%d\n", file, ret);
free(key);
diff --git a/core/adbd/base64.c b/core/adbd/base64.c
index 7270703..91fc1b2 100644
--- a/core/adbd/base64.c
+++ b/core/adbd/base64.c
@@ -134,7 +134,7 @@ static const char Pad64 = '=';
*/
int
-b64_ntop(src, srclength, target, targsize)
+adb_b64_ntop(src, srclength, target, targsize)
u_char const *src;
size_t srclength;
char *target;
@@ -212,7 +212,7 @@ b64_ntop(src, srclength, target, targsize)
*/
int
-b64_pton(src, target, targsize)
+adb_b64_pton(src, target, targsize)
char const *src;
u_char *target;
size_t targsize;
--
2.47.0

View File

@ -1,40 +0,0 @@
From 082ee80d3524fa3474644c09b441d7f7947675cc Mon Sep 17 00:00:00 2001
From: Gary Bisson <gary.bisson@boundarydevices.com>
Date: Sun, 1 Dec 2024 15:43:56 +0100
Subject: [PATCH] Fix build issue with uclibc
Signed-off-by: Gary Bisson <gary.bisson@boundarydevices.com>
---
core/adb/adb_auth_client.c | 2 +-
core/adbd/adb_auth_client.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/core/adb/adb_auth_client.c b/core/adb/adb_auth_client.c
index 0b4913e..068d837 100644
--- a/core/adb/adb_auth_client.c
+++ b/core/adb/adb_auth_client.c
@@ -72,7 +72,7 @@ static void read_keys(const char *file, struct listnode *list)
if (sep)
*sep = '\0';
- ret = __b64_pton(buf, (u_char *)&key->key, sizeof(key->key) + 4);
+ ret = b64_pton(buf, (u_char *)&key->key, sizeof(key->key) + 4);
if (ret != sizeof(key->key)) {
D("%s: Invalid base64 data ret=%d\n", file, ret);
free(key);
diff --git a/core/adbd/adb_auth_client.c b/core/adbd/adb_auth_client.c
index 0b4913e..068d837 100644
--- a/core/adbd/adb_auth_client.c
+++ b/core/adbd/adb_auth_client.c
@@ -72,7 +72,7 @@ static void read_keys(const char *file, struct listnode *list)
if (sep)
*sep = '\0';
- ret = __b64_pton(buf, (u_char *)&key->key, sizeof(key->key) + 4);
+ ret = b64_pton(buf, (u_char *)&key->key, sizeof(key->key) + 4);
if (ret != sizeof(key->key)) {
D("%s: Invalid base64 data ret=%d\n", file, ret);
free(key);
--
2.47.0