diff --git a/package/system/apk/Makefile b/package/system/apk/Makefile index f753b41f85b..f4ea0110d2c 100644 --- a/package/system/apk/Makefile +++ b/package/system/apk/Makefile @@ -5,9 +5,9 @@ PKG_RELEASE:=2 PKG_SOURCE_URL=https://gitlab.alpinelinux.org/alpine/apk-tools.git PKG_SOURCE_PROTO:=git -PKG_SOURCE_DATE:=2025-02-08 -PKG_SOURCE_VERSION:=34771ccb7964b0e7cb5d1fc64bd1b83fe73296ba -PKG_MIRROR_HASH:=fddd0334fa2ce7cc7fedb2cc95ee800caf9cbe43d617c2e612e2f58fc30b14c2 +PKG_SOURCE_DATE:=2025-06-06 +PKG_SOURCE_VERSION:=9331888de6bd5b280d75112e5b2f7b55684db0ec +PKG_MIRROR_HASH:=cf5b3429ce9ee5e2c4705b0b8160adec6f300dd2a42f8190fb0953754dd5eaa5 PKG_VERSION=3.0.0_pre$(subst -,,$(PKG_SOURCE_DATE)) diff --git a/package/system/apk/patches/0002-io_url_wget-correctly-init-wget_out-on-apk_io_url_in.patch b/package/system/apk/patches/0002-io_url_wget-correctly-init-wget_out-on-apk_io_url_in.patch deleted file mode 100644 index 305e367727b..00000000000 --- a/package/system/apk/patches/0002-io_url_wget-correctly-init-wget_out-on-apk_io_url_in.patch +++ /dev/null @@ -1,27 +0,0 @@ -From a50f7ea2dd023ef124c5209b487608b37dbeea7c Mon Sep 17 00:00:00 2001 -From: Christian Marangi -Date: Sat, 1 Mar 2025 19:33:18 +0100 -Subject: [PATCH] io_url_wget: correctly init wget_out on apk_io_url_init call - -Commit fc7768c09497 ("io_url_wget: log wget output using apk_process -api") reworked the implementation but forgot to init the static wget_out -on calling apk_io_url_init. This cause APK to SIGFAULT on apk update or -apk add when actually using the WGET method to download remote packages. - -Fix this by setting wget_out with the passed out from apk_io_url_init. - -Reported-by: John Crispin -Fixes: fc7768c09497 ("io_url_wget: log wget output using apk_process api") -Signed-off-by: Christian Marangi ---- - src/io_url_wget.c | 1 + - 1 file changed, 1 insertion(+) - ---- a/src/io_url_wget.c -+++ b/src/io_url_wget.c -@@ -48,4 +48,5 @@ void apk_io_url_set_redirect_callback(vo - - void apk_io_url_init(struct apk_out *out) - { -+ wget_out = out; - } diff --git a/package/system/apk/patches/0003-io-fix-undefined-behaviour-in-apk_istream_get_delim.patch b/package/system/apk/patches/0003-io-fix-undefined-behaviour-in-apk_istream_get_delim.patch deleted file mode 100644 index d32dd2541f7..00000000000 --- a/package/system/apk/patches/0003-io-fix-undefined-behaviour-in-apk_istream_get_delim.patch +++ /dev/null @@ -1,67 +0,0 @@ -From 55ab583de9a35ea79d63b8058a131ef260d407a9 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Timo=20Ter=C3=A4s?= -Date: Mon, 21 Apr 2025 12:22:04 +0300 -Subject: [PATCH] io: fix undefined behaviour in apk_istream_get_delim - -Arithmetics on null pointer are undefined, so leave is->ptr -pointing to is->buf always. Rewrite the function to be -a bit more readable. - -ref #11064, #11105 ---- - src/io.c | 38 +++++++++++++++++++++----------------- - 1 file changed, 21 insertions(+), 17 deletions(-) - ---- a/src/io.c -+++ b/src/io.c -@@ -191,29 +191,33 @@ int apk_istream_get_max(struct apk_istre - - int apk_istream_get_delim(struct apk_istream *is, apk_blob_t token, apk_blob_t *data) - { -- apk_blob_t ret = APK_BLOB_NULL, left = APK_BLOB_NULL; -- int r = 0; -+ int r; -+ -+ if (is->err && is->ptr == is->end) { -+ *data = APK_BLOB_NULL; -+ return is->err < 0 ? is->err : -APKE_EOF; -+ } - - do { -- if (apk_blob_split(APK_BLOB_PTR_LEN((char*)is->ptr, is->end - is->ptr), token, &ret, &left)) -- break; -+ apk_blob_t left; -+ if (apk_blob_split(APK_BLOB_PTR_LEN((char*)is->ptr, is->end - is->ptr), token, data, &left)) { -+ is->ptr = (uint8_t*)left.ptr; -+ is->end = (uint8_t*)left.ptr + left.len; -+ return 0; -+ } - r = __apk_istream_fill(is); - } while (r == 0); - -- /* Last segment before end-of-file. Return also zero length non-null -- * blob if eof comes immediately after the delimiter. */ -- if (is->ptr && r > 0) -- ret = APK_BLOB_PTR_LEN((char*)is->ptr, is->end - is->ptr); -- -- if (!APK_BLOB_IS_NULL(ret)) { -- is->ptr = (uint8_t*)left.ptr; -- is->end = (uint8_t*)left.ptr + left.len; -- *data = ret; -- return 0; -+ if (r < 0) { -+ *data = APK_BLOB_NULL; -+ return apk_istream_error(is, r); - } -- if (r < 0) apk_istream_error(is, r); -- *data = APK_BLOB_NULL; -- return r < 0 ? r : -APKE_EOF; -+ -+ /* EOF received. Return the last buffered data or an empty -+ * blob if EOF came directly after last separator. */ -+ *data = APK_BLOB_PTR_LEN((char*)is->ptr, is->end - is->ptr); -+ is->ptr = is->end = is->buf; -+ return 0; - } - - static void blob_get_meta(struct apk_istream *is, struct apk_file_meta *meta) diff --git a/package/system/apk/patches/0010-app_list-add-full-print.patch b/package/system/apk/patches/0010-app_list-add-full-print.patch index dd334303109..13a7663f2d3 100644 --- a/package/system/apk/patches/0010-app_list-add-full-print.patch +++ b/package/system/apk/patches/0010-app_list-add-full-print.patch @@ -12,21 +12,17 @@ Signed-off-by: Christian Marangi --- a/src/app_list.c +++ b/src/app_list.c -@@ -27,6 +27,7 @@ struct list_ctx { - unsigned int match_depends : 1; +@@ -49,12 +49,53 @@ struct list_ctx { unsigned int match_providers : 1; + unsigned int match_depends : 1; unsigned int manifest : 1; ++ unsigned int installed : 1; /* Solely for print_full patch */ + unsigned int full : 1; - - struct apk_string_array *filters; }; -@@ -105,6 +106,40 @@ static void print_manifest(const struct - printf("%s " BLOB_FMT "\n", pkg->name->name, BLOB_PRINTF(*pkg->version)); - } +static void print_full(const struct apk_package *pkg, const struct list_ctx *ctx) +{ -+ struct apk_dependency *d; ++ struct apk_dependency d; + + printf("Package: %s\n", pkg->name->name); + printf("Version: " BLOB_FMT "\n", BLOB_PRINTF(*pkg->version)); @@ -34,7 +30,7 @@ Signed-off-by: Christian Marangi + int i = 0; + + printf("Depends: "); -+ foreach_array_item(d, pkg->depends) { ++ apk_array_foreach(d, pkg->depends) { + i++; + printf("%s%s", d->name->name, i < apk_array_len(pkg->depends) ? ", ": "\n"); + } @@ -43,7 +39,7 @@ Signed-off-by: Christian Marangi + int i = 0; + + printf("Provides: "); -+ foreach_array_item(d, pkg->provides) { ++ apk_array_foreach(d, pkg->provides) { + i++; + printf("%s%s", d->name->name, i < apk_array_len(pkg->provides) ? ", ": "\n"); + } @@ -58,35 +54,41 @@ Signed-off-by: Christian Marangi + printf("\n"); +} + - static void filter_package(const struct apk_database *db, const struct apk_package *pkg, const struct list_ctx *ctx, const struct apk_name *name) + static void print_package(const struct apk_database *db, const struct apk_name *name, const struct apk_package *pkg, const struct list_ctx *ctx) { - if (ctx->match_origin && !origin_matches(ctx, pkg)) return; -@@ -114,7 +149,9 @@ static void filter_package(const struct - if (ctx->upgradable && !is_upgradable(db, pkg)) return; - if (ctx->match_providers) printf("<%s> ", name->name); -- if (ctx->manifest) -+ if (ctx->full) + ++ if (ctx->full) { + print_full(pkg, ctx); -+ else if (ctx->manifest) - print_manifest(pkg, ctx); - else - print_package(db, pkg, ctx); -@@ -154,6 +191,7 @@ static int print_result(struct apk_datab ++ return; ++ } ++ + if (ctx->manifest) { + printf("%s " BLOB_FMT "\n", pkg->name->name, BLOB_PRINTF(*pkg->version)); + return; +@@ -96,6 +137,7 @@ static void print_package(const struct apk_database *db, const struct apk_name * OPT(OPT_LIST_depends, APK_OPT_SH("d") "depends") \ - OPT(OPT_LIST_installed, APK_OPT_SH("I") "installed") \ + OPT(OPT_LIST_installed, APK_OPT_SH("I")) \ OPT(OPT_LIST_manifest, "manifest") \ + OPT(OPT_LIST_full, "full") \ OPT(OPT_LIST_origin, APK_OPT_SH("o") "origin") \ - OPT(OPT_LIST_orphaned, APK_OPT_SH("O") "orphaned") \ + OPT(OPT_LIST_orphaned, APK_OPT_SH("O")) \ OPT(OPT_LIST_providers, APK_OPT_SH("P") "providers") \ -@@ -167,6 +205,9 @@ static int list_parse_option(void *pctx, - struct list_ctx *ctx = pctx; +@@ -109,6 +151,9 @@ static int list_parse_option(void *pctx, struct apk_ctx *ac, int opt, const char + struct apk_query_spec *qs = &ac->query; switch (opt) { + case OPT_LIST_full: + ctx->full = 1; + break; case OPT_LIST_available: - ctx->available = 1; - ctx->orphaned = 0; + qs->filter.available = 1; + break; +@@ -117,6 +162,7 @@ static int list_parse_option(void *pctx, struct apk_ctx *ac, int opt, const char + break; + case OPT_LIST_installed: + installed: ++ ctx->installed = 1; + qs->filter.installed = 1; + ac->open_flags |= APK_OPENF_NO_SYS_REPOS; + break;