From patchwork Thu Nov 1 18:51:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yifeng Sun X-Patchwork-Id: 992057 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="KjRt2zAN"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42mDps0ZB5zB4Yx for ; Fri, 2 Nov 2018 05:52:36 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 6CC8CCFC; Thu, 1 Nov 2018 18:51:29 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 40CC6BE7 for ; Thu, 1 Nov 2018 18:51:28 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id F014A7E8 for ; Thu, 1 Nov 2018 18:51:27 +0000 (UTC) Received: by mail-pg1-f194.google.com with SMTP id z17-v6so9444497pgv.3 for ; Thu, 01 Nov 2018 11:51:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=8S0wOtp/kzPdoECzt/NR1iJIRFcJjLC6ShlCANYUgZg=; b=KjRt2zANih5iRL9d1CwP50+4JOLzul9KwXvDFnms621bAqBBeOQJInYknZRaZFA+mN 8oDJRURYWpmDwPFJ3z65MA9lIwej/qtiFJg5TqqEJ/PJ6R7/1Ze6eoNj3ty/Jnlxyq9h YZEHeC8kUhydHMuHVWJ+wvRVzRDU/Ev8X69FDooxFkOhU//FT15ibSTjwWztGxvVR+o5 gpW/z8TauGzpk3fP5GhgzwhlyO99eedh0XUgJHpVG8awICJR8vY2vK+QsUHik2xURg3V JY9DZj9GOdlU3h5cTIUzQfw8XMmsUznGlwUlfN5EYuqHJ3+ncddGFLXZqRxsyY+dcV6D oezg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=8S0wOtp/kzPdoECzt/NR1iJIRFcJjLC6ShlCANYUgZg=; b=iTm1OGhnYkCZvdJYk4EcbMaYKOxI/hmUk8o5hsGFPE2Avm2CsDxq/UlTqsoSBbo8MX +rPoGaTqS9n5qEn75wCtmC24Fj/1SF0HHywDcQGYZ26GH3aApb+bWDeWL+0YcNz38QOW q/RScJqfWMuVgBfeenskXIf6Nfq7gSnt+ZDzg0XGEsWHzhkuWn+go5jJtcMW2AbO8o42 G1kslicK9N05XR6wKXQqr6Vb5RF57H2nUKa3fc7lEAh2O8pf++JfOsqXuvfrq+5yaEuA +3ptPYsx5WJyoLsJwcuKFAfPaM03KRt53aRzS384pDb+Al3IcYf2GYBpjWXS1sRzSD8y +Sng== X-Gm-Message-State: AGRZ1gJPF/nPoJtq2g/QzKh3ql8kA4DL7WFqYTF1cCfLGwesvrWLUaPP +4a74+XbGVNPjGw+4GPvjLI5eRjD X-Google-Smtp-Source: AJdET5f0ggYUu81vwZAZ06HGAWhBP1/OpMYGg9ICRo2CnDW4cStsfuTGbQ0W2q1l03AhypD3FBQUxA== X-Received: by 2002:a62:89d7:: with SMTP id n84-v6mr8913032pfk.255.1541098287304; Thu, 01 Nov 2018 11:51:27 -0700 (PDT) Received: from kern417.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id e131-v6sm5768015pfc.122.2018.11.01.11.51.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Nov 2018 11:51:26 -0700 (PDT) From: Yifeng Sun To: dev@openvswitch.org Date: Thu, 1 Nov 2018 11:51:21 -0700 Message-Id: <1541098281-18548-1-git-send-email-pkusunyifeng@gmail.com> X-Mailer: git-send-email 2.7.4 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH] oss-fuzz: Use unsigned for left shift in ofctl_parse_flows__ X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Left shift int (1 here) can result in a negative value. This is an undefined behavior according to ISO C99 (6.5.7). The error message reported by oss-fuzz is: runtime error: left shift of 1 by 31 places cannot be represented in type 'int' This patch fixes it by changing signed int to unsigned int. Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11166 Signed-off-by: Yifeng Sun --- tests/oss-fuzz/ofctl_parse_target.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/oss-fuzz/ofctl_parse_target.c b/tests/oss-fuzz/ofctl_parse_target.c index 8a906400a5cc..fbd91bdd3e81 100644 --- a/tests/oss-fuzz/ofctl_parse_target.c +++ b/tests/oss-fuzz/ofctl_parse_target.c @@ -24,7 +24,7 @@ ofctl_parse_flows__(struct ofputil_flow_mod *fms, size_t n_fms, printf("no usable protocol\n"); } for (i = 0; i < sizeof(enum ofputil_protocol) * CHAR_BIT; i++) { - protocol = 1 << i; + protocol = 1u << i; if (protocol & usable_protocols & OFPUTIL_P_ANY) { break; }