diff options
author | Timo Teräs <timo.teras@iki.fi> | 2022-12-22 14:47:16 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2022-12-22 14:47:16 +0200 |
commit | 101c8684ac7e924bf9097e8cff4c88e3f0eb7923 (patch) | |
tree | 2ced628deea3eeb2eb749502e911d1811fa254c4 /src/apk.c | |
parent | d561bd7c86f63ec3693e3c3c8479302b8c6bdc5f (diff) | |
download | apk-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.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -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); |