aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Groffen <grobian@gentoo.org>2020-01-04 14:39:53 +0100
committerFabian Groffen <grobian@gentoo.org>2020-01-04 14:39:53 +0100
commit123d916b0ce9eaeb53c2d06ad6504729af8688ee (patch)
treed34a41b645e3dbb91a79b81f1e45101dae7f61d2 /qkeyword.c
parentqkeyword/qlist: replace strtok by strtok_r (diff)
downloadportage-utils-123d916b0ce9eaeb53c2d06ad6504729af8688ee.tar.gz
portage-utils-123d916b0ce9eaeb53c2d06ad6504729af8688ee.tar.bz2
portage-utils-123d916b0ce9eaeb53c2d06ad6504729af8688ee.zip
qkeyword: avoid NULL derefence if strtok_r's initial call returns NULL
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
Diffstat (limited to 'qkeyword.c')
-rw-r--r--qkeyword.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/qkeyword.c b/qkeyword.c
index 0078fdaf..9c768586 100644
--- a/qkeyword.c
+++ b/qkeyword.c
@@ -190,13 +190,13 @@ read_keywords(char *s, int *keywords)
if (!slen)
return 0;
- arch = strtok_r(s, delim, &savep);
- do {
+ while ((arch = strtok_r(s, delim, &savep)) != NULL) {
+ s = NULL; /* for strtok_r */
i = decode_arch(arch);
if (i == -1)
continue;
keywords[i] = decode_status(arch[0]);
- } while ((arch = strtok_r(NULL, delim, &savep)));
+ }
return 0;
}