From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 2D8AB138334 for ; Sat, 4 Jan 2020 19:48:34 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 06FB2E0922; Sat, 4 Jan 2020 19:48:32 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id E4C64E0922 for ; Sat, 4 Jan 2020 19:48:31 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 929B434DDA8 for ; Sat, 4 Jan 2020 19:48:30 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id C9C54A8 for ; Sat, 4 Jan 2020 19:48:28 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1578145193.123d916b0ce9eaeb53c2d06ad6504729af8688ee.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: qkeyword.c X-VCS-Directories: / X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 123d916b0ce9eaeb53c2d06ad6504729af8688ee X-VCS-Branch: master Date: Sat, 4 Jan 2020 19:48:28 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: c22f2459-bb84-44ed-9c73-fe99113a8cac X-Archives-Hash: f4b861bd175b341f656f2c04e33ebf78 commit: 123d916b0ce9eaeb53c2d06ad6504729af8688ee Author: Fabian Groffen gentoo org> AuthorDate: Sat Jan 4 13:39:53 2020 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Sat Jan 4 13:39:53 2020 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=123d916b qkeyword: avoid NULL derefence if strtok_r's initial call returns NULL Signed-off-by: Fabian Groffen gentoo.org> qkeyword.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qkeyword.c b/qkeyword.c index 0078fda..9c76858 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; }