0003-Adjust-base64-function-handling.patch 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. From 946dbb00fe4b2a75c688a470fc0c3924aa018a24 Mon Sep 17 00:00:00 2001
  2. From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  3. Date: Sun, 14 Jul 2024 11:39:49 +0200
  4. Subject: [PATCH] Adjust base64 function handling
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. In order to support libcs that do not provide b64_pton(), one of the
  9. Debian patches adds a copy of b64_pton() and b64_ntop(). However, no
  10. prototype is added for those functions, causing an "implicit
  11. declaration" warning... or error depending on the compiler version
  12. used:
  13. core/adbd/adb_auth_client.c:75:15: error: implicit declaration of function ‘b64_pton’ [-Wimplicit-function-declaration]
  14. This patch adds appropriate prototypes, but while at it, also renames
  15. the internal copy of b64_*() functions to have an adb_ prefix in order
  16. to clarify things and not clash with definitions potentially coming
  17. from the C library.
  18. Upstream: N/A, we're too far from upstream
  19. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  20. ---
  21. core/adb/adb_auth_client.c | 3 ++-
  22. core/adbd/adb_auth_client.c | 3 ++-
  23. core/adbd/base64.c | 4 ++--
  24. 3 files changed, 6 insertions(+), 4 deletions(-)
  25. diff --git a/core/adb/adb_auth_client.c b/core/adb/adb_auth_client.c
  26. index 0b4913e..25b9828 100644
  27. --- a/core/adb/adb_auth_client.c
  28. +++ b/core/adb/adb_auth_client.c
  29. @@ -45,6 +45,7 @@ static char *key_paths[] = {
  30. static fdevent listener_fde;
  31. static int framework_fd = -1;
  32. +extern int adb_b64_pton(char const *src, u_char *target, size_t targsize);
  33. static void read_keys(const char *file, struct listnode *list)
  34. {
  35. @@ -72,7 +73,7 @@ static void read_keys(const char *file, struct listnode *list)
  36. if (sep)
  37. *sep = '\0';
  38. - ret = __b64_pton(buf, (u_char *)&key->key, sizeof(key->key) + 4);
  39. + ret = adb_b64_pton(buf, (u_char *)&key->key, sizeof(key->key) + 4);
  40. if (ret != sizeof(key->key)) {
  41. D("%s: Invalid base64 data ret=%d\n", file, ret);
  42. free(key);
  43. diff --git a/core/adbd/adb_auth_client.c b/core/adbd/adb_auth_client.c
  44. index 0b4913e..25b9828 100644
  45. --- a/core/adbd/adb_auth_client.c
  46. +++ b/core/adbd/adb_auth_client.c
  47. @@ -45,6 +45,7 @@ static char *key_paths[] = {
  48. static fdevent listener_fde;
  49. static int framework_fd = -1;
  50. +extern int adb_b64_pton(char const *src, u_char *target, size_t targsize);
  51. static void read_keys(const char *file, struct listnode *list)
  52. {
  53. @@ -72,7 +73,7 @@ static void read_keys(const char *file, struct listnode *list)
  54. if (sep)
  55. *sep = '\0';
  56. - ret = __b64_pton(buf, (u_char *)&key->key, sizeof(key->key) + 4);
  57. + ret = adb_b64_pton(buf, (u_char *)&key->key, sizeof(key->key) + 4);
  58. if (ret != sizeof(key->key)) {
  59. D("%s: Invalid base64 data ret=%d\n", file, ret);
  60. free(key);
  61. diff --git a/core/adbd/base64.c b/core/adbd/base64.c
  62. index 7270703..91fc1b2 100644
  63. --- a/core/adbd/base64.c
  64. +++ b/core/adbd/base64.c
  65. @@ -134,7 +134,7 @@ static const char Pad64 = '=';
  66. */
  67. int
  68. -b64_ntop(src, srclength, target, targsize)
  69. +adb_b64_ntop(src, srclength, target, targsize)
  70. u_char const *src;
  71. size_t srclength;
  72. char *target;
  73. @@ -212,7 +212,7 @@ b64_ntop(src, srclength, target, targsize)
  74. */
  75. int
  76. -b64_pton(src, target, targsize)
  77. +adb_b64_pton(src, target, targsize)
  78. char const *src;
  79. u_char *target;
  80. size_t targsize;
  81. --
  82. 2.47.0