aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Groffen <grobian@gentoo.org>2020-07-08 10:11:38 +0200
committerFabian Groffen <grobian@gentoo.org>2020-07-08 10:11:38 +0200
commitbee2b445ae583187d2b8218a5b1429828f872663 (patch)
tree60b6dc6d2b694f68e1cd4bd9915ea8ec67fe7110
parentqpkg: replace allocated buf with stack version (diff)
downloadportage-utils-bee2b445ae583187d2b8218a5b1429828f872663.tar.gz
portage-utils-bee2b445ae583187d2b8218a5b1429828f872663.tar.bz2
portage-utils-bee2b445ae583187d2b8218a5b1429828f872663.zip
qlop: fix crash when encountering a long option with -E -v
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
-rw-r--r--qlop.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/qlop.c b/qlop.c
index 5048b1e..a5761d7 100644
--- a/qlop.c
+++ b/qlop.c
@@ -545,7 +545,7 @@ static int do_emerge_log(
char shortopts[8]; /* must hold as many opts converted below */
int numopts = 0;
- printf("emerge");
+ printf("%semerge%s", DKBLUE, NORM);
for (p += 13; (q = strtok(p, " \n")) != NULL; p = NULL) {
if (strncmp(q, "--", 2) == 0) {
/* portage seems to normalise options given into
@@ -556,24 +556,31 @@ static int do_emerge_log(
q += 2;
if (strcmp(q, "ask") == 0) {
shortopts[numopts++] = 'a';
+ q = NULL;
} else if (strcmp(q, "verbose") == 0) {
shortopts[numopts++] = 'v';
+ q = NULL;
} else if (strcmp(q, "oneshot") == 0) {
shortopts[numopts++] = '1';
+ q = NULL;
} else if (strcmp(q, "deep") == 0) {
shortopts[numopts++] = 'D';
+ q = NULL;
} else if (strcmp(q, "update") == 0) {
shortopts[numopts++] = 'u';
+ q = NULL;
} else if (strcmp(q, "depclean") == 0) {
shortopts[numopts++] = 'c';
+ q = NULL;
} else if (strcmp(q, "unmerge") == 0) {
shortopts[numopts++] = 'C';
- } else {
q = NULL;
+ } else {
+ q -= 2;
}
/* process next token */
- if (q != NULL)
+ if (q == NULL)
continue;
}
@@ -590,7 +597,7 @@ static int do_emerge_log(
}
if (strncmp(q, "--", 2) == 0) {
- printf(" %s--%s%s", GREEN, q, NORM);
+ printf(" %s%s%s", GREEN, q, NORM);
} else if (strcmp(q, "@world") == 0 ||
strcmp(q, "@system") == 0)
{