summaryrefslogtreecommitdiff
path: root/src/apk.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2022-12-22 14:47:16 +0200
committerTimo Teräs <timo.teras@iki.fi>2022-12-22 14:47:16 +0200
commit101c8684ac7e924bf9097e8cff4c88e3f0eb7923 (patch)
tree2ced628deea3eeb2eb749502e911d1811fa254c4 /src/apk.c
parentd561bd7c86f63ec3693e3c3c8479302b8c6bdc5f (diff)
downloadapk-tools-101c8684ac7e924bf9097e8cff4c88e3f0eb7923.tar.gz
apk-tools-101c8684ac7e924bf9097e8cff4c88e3f0eb7923.tar.bz2
apk-tools-101c8684ac7e924bf9097e8cff4c88e3f0eb7923.tar.xz
apk-tools-101c8684ac7e924bf9097e8cff4c88e3f0eb7923.zip
apk: remove empty arguments
fixes #10848
Diffstat (limited to 'src/apk.c')
-rw-r--r--src/apk.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/apk.c b/src/apk.c
index 448e388..94520c1 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -433,6 +433,16 @@ static void on_sigint(int s)
exit(128 + s);
}
+static int remove_empty_strings(int count, char **args)
+{
+ int i, j;
+ for (i = j = 0; i < count; i++) {
+ args[j] = args[i];
+ if (args[j][0]) j++;
+ }
+ return j;
+}
+
int main(int argc, char **argv)
{
void *ctx = NULL;
@@ -486,6 +496,7 @@ int main(int argc, char **argv)
argc--;
argv++;
}
+ argc = remove_empty_strings(argc, argv);
apk_db_init(&db);
signal(SIGINT, on_sigint);