From nobody Mon May 6 11:43:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519068642432224.4180805929126; Mon, 19 Feb 2018 11:30:42 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5AFC2356F4; Mon, 19 Feb 2018 19:30:39 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9C567608F0; Mon, 19 Feb 2018 19:30:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 886F74A46C; Mon, 19 Feb 2018 19:30:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1JJUZWR013119 for ; Mon, 19 Feb 2018 14:30:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id F2E2D10AF9F8; Mon, 19 Feb 2018 19:30:34 +0000 (UTC) Received: from vhost2.laine.org (ovpn-116-171.phx2.redhat.com [10.3.116.171]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B9A2111DCF8 for ; Mon, 19 Feb 2018 19:30:32 +0000 (UTC) From: Laine Stump To: libvir-list@redhat.com Date: Mon, 19 Feb 2018 14:30:19 -0500 Message-Id: <20180219193019.23177-1-laine@laine.org> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] nwfilter: assure that virNWFilterSnoop(Eth|Dhcp)Hdr objects don't change size X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 19 Feb 2018 19:30:40 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" These two objects are used to access fields in actual ethernet packets captures with libpcap, so it's essential that they don't change size for any reason. This patch uses gnulib's verify() macro to make sure their sizes don't change. Signed-off-by: Laine Stump Reviewed-by: Daniel P. Berrang=C3=A9 --- danpb suggested doing this in his response to my patch fixing virMacAddr: https://www.redhat.com/archives/libvir-list/2018-February/msg00850.html I decided to make it a separate patch from the virMacAddr fix. src/nwfilter/nwfilter_dhcpsnoop.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcp= snoop.c index 743136277d..8e955150fa 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -195,6 +195,7 @@ struct _virNWFilterSnoopEthHdr { uint16_t eh_type; uint8_t eh_data[]; } ATTRIBUTE_PACKED; +verify(sizeof(struct _virNWFilterSnoopEthHdr) =3D=3D 14); =20 typedef struct _virNWFilterSnoopDHCPHdr virNWFilterSnoopDHCPHdr; typedef virNWFilterSnoopDHCPHdr *virNWFilterSnoopDHCPHdrPtr; @@ -216,6 +217,7 @@ struct _virNWFilterSnoopDHCPHdr { char d_file[128]; uint8_t d_opts[]; } ATTRIBUTE_PACKED; +verify(sizeof(struct _virNWFilterSnoopDHCPHdr) =3D=3D 236); =20 /* DHCP options */ =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list