diff mbox series

[meta-oe] android-tools: fix adb OpenSSL patch (really make compatible with >= v1.1)

Message ID 20240530091132.2978796-1-andre.draszik@linaro.org
State New
Headers show
Series [meta-oe] android-tools: fix adb OpenSSL patch (really make compatible with >= v1.1) | expand

Commit Message

André Draszik May 30, 2024, 9:11 a.m. UTC
As per the inlined patch commit message, gcc 14 is highlighting a few
issues with the existing patch and it doesn't compile.

Update the patch to fix.

Note there are two recipes for android-tools in this layer - the recipe
here and another one in
meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools. A patch
for the alternative android-tools version had already been posted, so
this patch only deals with the remaining one.

Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 .../android-tools/core/adb_libssl_11.diff     | 68 ++++++++++++++-----
 1 file changed, 50 insertions(+), 18 deletions(-)
diff mbox series

Patch

diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/adb_libssl_11.diff b/meta-oe/recipes-devtools/android-tools/android-tools/core/adb_libssl_11.diff
index 177d69a97a3e..5ba576fe84d4 100644
--- a/meta-oe/recipes-devtools/android-tools/android-tools/core/adb_libssl_11.diff
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/core/adb_libssl_11.diff
@@ -1,29 +1,54 @@ 
-Description: adb: Make compatible with openssl 1.1
- OpenSSL version 1.1 brought some API changes which broke the build here,
- fix that by accessing rsa->n (and e) directly, using RSA_get0_key instead.
-Author: Chirayu Desai <chirayudesai1@gmail.com
-Last-Update: 2016-11-10
----
-Upstream-Status: Pending
+From 9fd6f6f234de245916ea9df4ca76fabeb99561a6 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Andr=C3=A9=20Draszik?= <andre.draszik@linaro.org>
+Date: Mon, 27 May 2024 10:54:08 +0100
+Subject: [PATCH] adb: (really) make compatible with openssl 1.1
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
 
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
----
-Upstream-Status: Pending
+Compiling using gcc 14 results in the following:
+
+| .../android-tools/5.1.1.r37/git/system/core/adb/adb_auth_host.c:86:23: error: passing argument 2 of 'RSA_get0_key' from incompatible pointer type [-Wincompatible-pointer-types]
+|    86 |     RSA_get0_key(rsa, &n, &e, NULL);
+|       |                       ^~
+|       |                       |
+|       |                       BIGNUM ** {aka struct bignum_st **}
+| .../android-tools/5.1.1.r37/recipe-sysroot/usr/include/openssl/rsa.h:229:56: note: expected 'const BIGNUM **' {aka 'const struct bignum_st **'} but argument is of type 'BIGNUM **' {aka 'struct bignum_st **'}
+|   229 |                                         const BIGNUM **n, const BIGNUM **e,
+|       |                                         ~~~~~~~~~~~~~~~^
+| .../android-tools/5.1.1.r37/git/system/core/adb/adb_auth_host.c:86:27: error: passing argument 3 of 'RSA_get0_key' from incompatible pointer type [-Wincompatible-pointer-types]
+|    86 |     RSA_get0_key(rsa, &n, &e, NULL);
+|       |                           ^~
+|       |                           |
+|       |                           BIGNUM ** {aka struct bignum_st **}
+| .../android-tools/5.1.1.r37/recipe-sysroot/usr/include/openssl/rsa.h:229:74: note: expected 'const BIGNUM **' {aka 'const struct bignum_st **'} but argument is of type 'BIGNUM **' {aka 'struct bignum_st **'}
+|   229 |                                         const BIGNUM **n, const BIGNUM **e,
+|       |                                                           ~~~~~~~~~~~~~~~^
+
+Update the code to correct usage of the OpenSSL APIs.
 
- system/core/adb/adb_auth_host.c |    5 +++--
- 1 file changed, 3 insertions(+), 2 deletions(-)
+Signed-off-by: André Draszik <andre.draszik@linaro.org>
 
+---
+Upstream-Status: Inappropriate (ancient version of android-tools)
+---
+ adb/adb_auth_host.c | 7 +++----
+ 1 file changed, 3 insertions(+), 4 deletions(-)
+
+diff --git a/adb/adb_auth_host.c b/adb/adb_auth_host.c
+index dd839001b5a3..a24e9bd89a7a 100644
 --- a/adb/adb_auth_host.c
 +++ b/adb/adb_auth_host.c
-@@ -75,6 +75,7 @@ static int RSA_to_RSAPublicKey(RSA *rsa,
+@@ -73,7 +73,7 @@ static int RSA_to_RSAPublicKey(RSA *rsa, RSAPublicKey *pkey)
+     BIGNUM* rr = BN_new();
+     BIGNUM* r = BN_new();
      BIGNUM* rem = BN_new();
-     BIGNUM* n = BN_new();
+-    BIGNUM* n = BN_new();
++    const BIGNUM* n = NULL, *e = NULL;
      BIGNUM* n0inv = BN_new();
-+    BIGNUM* e = BN_new();
  
      if (RSA_size(rsa) != RSANUMBYTES) {
-         ret = 0;
-@@ -82,7 +83,7 @@ static int RSA_to_RSAPublicKey(RSA *rsa,
+@@ -82,7 +82,7 @@ static int RSA_to_RSAPublicKey(RSA *rsa, RSAPublicKey *pkey)
      }
  
      BN_set_bit(r32, 32);
@@ -32,7 +57,7 @@  Upstream-Status: Pending
      BN_set_bit(r, RSANUMWORDS * 32);
      BN_mod_sqr(rr, r, n, ctx);
      BN_div(NULL, rem, n, r32, ctx);
-@@ -96,7 +97,7 @@ static int RSA_to_RSAPublicKey(RSA *rsa,
+@@ -96,11 +96,10 @@ static int RSA_to_RSAPublicKey(RSA *rsa, RSAPublicKey *pkey)
          BN_div(n, rem, n, r32, ctx);
          pkey->n[i] = BN_get_word(rem);
      }
@@ -41,3 +66,10 @@  Upstream-Status: Pending
  
  out:
      BN_free(n0inv);
+-    BN_free(n);
+     BN_free(rem);
+     BN_free(r);
+     BN_free(rr);
+-- 
+2.45.1.288.g0e0cd299f1-goog
+