From patchwork Thu May 6 17:54:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 1475184 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Fbh6b1Tdfz9sW4 for ; Fri, 7 May 2021 03:54:31 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id A896E40E7C; Thu, 6 May 2021 17:54:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nMwv2TISELmC; Thu, 6 May 2021 17:54:25 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTP id 3F8BC403B8; Thu, 6 May 2021 17:54:24 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 206E0C000F; Thu, 6 May 2021 17:54:24 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0D51CC0022 for ; Thu, 6 May 2021 17:54:22 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id D908F40E4C for ; Thu, 6 May 2021 17:54:21 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LSU0jTYY9jEJ for ; Thu, 6 May 2021 17:54:21 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by smtp2.osuosl.org (Postfix) with ESMTPS id 1EF8C402AF for ; Thu, 6 May 2021 17:54:20 +0000 (UTC) X-Originating-IP: 75.54.222.30 Received: from sigfpe.attlocal.net (75-54-222-30.lightspeed.rdcyca.sbcglobal.net [75.54.222.30]) (Authenticated sender: blp@ovn.org) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id B32DCFF80E; Thu, 6 May 2021 17:54:18 +0000 (UTC) From: Ben Pfaff To: dev@openvswitch.org Date: Thu, 6 May 2021 10:54:08 -0700 Message-Id: <20210506175410.344793-2-blp@ovn.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210506175410.344793-1-blp@ovn.org> References: <20210506175410.344793-1-blp@ovn.org> MIME-Version: 1.0 Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 1/3] ofp-group: Use big-enough buffer in ofputil_format_group(). 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: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" GCC 11 pointed out that ofputil_group_to_string()'s prototype asks for a buffer with one byte more than supplied. This fixes the problem. This wasn't a buffer overflow because ofputil_group_to_string() honors the buffer size passed in, which was correct. The worst that could happen was truncating the last byte of a group name. Signed-off-by: Ben Pfaff --- lib/ofp-group.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ofp-group.c b/lib/ofp-group.c index bf0f8af544c9..737f48047b10 100644 --- a/lib/ofp-group.c +++ b/lib/ofp-group.c @@ -64,7 +64,7 @@ ofputil_group_from_string(const char *s, uint32_t *group_idp) void ofputil_format_group(uint32_t group_id, struct ds *s) { - char name[MAX_GROUP_NAME_LEN]; + char name[MAX_GROUP_NAME_LEN + 1]; ofputil_group_to_string(group_id, name, sizeof name); ds_put_cstr(s, name);