From patchwork Sat May 6 06:53:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhiqi Chen X-Patchwork-Id: 1778009 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=google header.b=AfA3ifuk; dkim-atps=neutral Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QDBjl58p2z1ydV for ; Sun, 7 May 2023 01:46:19 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 495B361162; Sat, 6 May 2023 15:46:17 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 495B361162 Authentication-Results: smtp3.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=google header.b=AfA3ifuk X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id n4eI476kDoIO; Sat, 6 May 2023 15:46:16 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 5B5FE607AA; Sat, 6 May 2023 15:46:15 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 5B5FE607AA Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 23670C0037; Sat, 6 May 2023 15:46:15 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 07549C002A for ; Sat, 6 May 2023 06:53:39 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id CA23881375 for ; Sat, 6 May 2023 06:53:39 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org CA23881375 Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=google header.b=AfA3ifuk X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id C9ziSqlI0fGW for ; Sat, 6 May 2023 06:53:37 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 799A981301 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by smtp1.osuosl.org (Postfix) with ESMTPS id 799A981301 for ; Sat, 6 May 2023 06:53:37 +0000 (UTC) Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-52c6f8ba7e3so2423990a12.3 for ; Fri, 05 May 2023 23:53:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1683356016; x=1685948016; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=MkXrI1h7f9P8UIlQOewLg9EZM9Sc4jlJAWfqdpuci6M=; b=AfA3ifuk+REllYy4WkBnlYDjY/HjqmdDfEdl5iisPdoRF4cH/lHMxKcOsPMOkI6zHl YFLexwwTlGxRe9y1MLQJmQBbQoZSA2+rRhOO6Ye9IflzxNrj2F7vmo1zBMOJ8SPf5BBo lGpcQizmzSTEqFTQtEZ1CZHpJ8Sal/GafOl51hEV3CozvjL7gQwruwdShu4MVX2CYfh7 c0QoSIHU2q5XXRjCKHfol9Mytl9e9oikOnt6GHaEWiiTirv4QktXX0zdKLtwonz7COyY /F47kYDCHmMWdBRNShqKePAssuMSWL8JI8QD3l/78polJG6xCO7VPg+7u0wiCbaYY12h 9+vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683356016; x=1685948016; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=MkXrI1h7f9P8UIlQOewLg9EZM9Sc4jlJAWfqdpuci6M=; b=XuuB+QJ+5q6LEpB01ZFefjdk+ujqKcn4mYHQ+pMgFj1rHJXPYmimkxr+DrkG9qG8Pa 8zCog4k/0XCId3OGTVEZyEJrU/YvUlmS+Jv5kkwGy4A7nUMTBF4dEBLgPxzFNcjMPz5z VnZQ7B/z1789EOmycj36ms+MHguhrR2M8gjmNJ7OPc9C1iW5h6Le4F4hGwIF8yV3aEat aELRCtpG2dli1Mvm1kqBNFzzzHByMjZxxbS0JIpkZ/4F+O/Bt4yRUGokGE3XpCVrH324 ONsvHGm389Y7pPGUpNX3nv7iOP7DJ7Yp5+M0ifFjqR8IF3qfJ2JdJoC4ietl3dq0uhq5 TQPA== X-Gm-Message-State: AC+VfDyPTIW2CWuNMcHuhtrjbXK4Su5utZPuKx38z7kA7COrhUzYNL+j uzprJAqcyAx3BMwAiUPdn2B/WFPZBYjQzHk7yU0y X-Google-Smtp-Source: ACHHUZ7hsnG/lbzJmQEUqaoKUp2FlalwxUwTROGMzSvpdQC+/lW4SrFad3bwHrqsbewK3rMqYpwMow== X-Received: by 2002:a17:902:b20a:b0:1ac:3e90:7c4 with SMTP id t10-20020a170902b20a00b001ac3e9007c4mr3549928plr.2.1683356016521; Fri, 05 May 2023 23:53:36 -0700 (PDT) Received: from YFW59KGR4V.bytedance.net ([61.213.176.13]) by smtp.gmail.com with ESMTPSA id g22-20020a1709029f9600b001aaff9be643sm2840517plq.89.2023.05.05.23.53.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 05 May 2023 23:53:36 -0700 (PDT) To: dev@openvswitch.org Date: Sat, 6 May 2023 14:53:09 +0800 Message-Id: <20230506065309.89052-1-chenzhiqi.123@bytedance.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) MIME-Version: 1.0 X-Mailman-Approved-At: Sat, 06 May 2023 15:46:14 +0000 Cc: Zhiqi Chen Subject: [ovs-dev] [PATCH] dpctl: Fix dereferencing null pointer in parse_ct_limit_zones(). X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Zhiqi Chen via dev From: Zhiqi Chen Reply-To: Zhiqi Chen Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Command with empty string following "dpctl/ct-get-limits zone=" such as "ovs-appctl dpctl/ct-get-limits zone=" will cause parse_ct_limit_zones() dereferencing null. Signed-off-by: Zhiqi Chen --- lib/dpctl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/dpctl.c b/lib/dpctl.c index 3ba40fa8f..15950bd50 100644 --- a/lib/dpctl.c +++ b/lib/dpctl.c @@ -2206,7 +2206,7 @@ parse_ct_limit_zones(const char *argv, struct ovs_list *zone_limits, argcopy = xstrdup(argv + 5); next_zone = strtok_r(argcopy, ",", &save_ptr); - do { + while (next_zone != NULL) { if (ovs_scan(next_zone, "%"SCNu16, &zone)) { ct_dpif_push_zone_limit(zone_limits, zone, 0, 0); } else { @@ -2214,7 +2214,8 @@ parse_ct_limit_zones(const char *argv, struct ovs_list *zone_limits, free(argcopy); return EINVAL; } - } while ((next_zone = strtok_r(NULL, ",", &save_ptr)) != NULL); + next_zone = strtok_r(NULL, ",", &save_ptr); + } free(argcopy); return 0;