From nobody Fri May 17 06:07:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1660898497; cv=none; d=zohomail.com; s=zohoarc; b=Hg+HG8wcayD+nn5zp80nlFJBb6VQqPKSTp6ehA/yT6nzqEG1g+KVDzYv8e+JhbveOhSfKhWB3zvZNrYAZRwr/HrRONgY/FShvvhj4Vb00qvBBzz8lHwa3OvkPsVMKX/hhiUrn7WHcwxDcoFlQCeHi428jjo1+DMXH8JUk6gvg+s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660898497; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=EmudL4/Cp8cKJHyxThVP+07mrtiHjMRQJGi/dfLyfaQ=; b=WSD0gCg+Do+JlifJuM4RCwmVxrcB251+gd3TUrJv6g41oanbTYP+JNVcnLehENijwA4hhIdtxoAY791xM1FBbT4Aj2spQv6YZsz+9WzAKsyuYGUHM161cd7RPDdehKv2TEO4kpXvF+uJG8Cu3ZWd+8ua1Sq2c06elsd1B7ANmIw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 166089849726131.0806602744492; Fri, 19 Aug 2022 01:41:37 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-501-Rk6DxGjoMrOojlJn8x8oUQ-1; Fri, 19 Aug 2022 04:41:31 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9722A8032F6; Fri, 19 Aug 2022 08:41:29 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43824C15BBA; Fri, 19 Aug 2022 08:41:27 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 14239194F4BC; Fri, 19 Aug 2022 08:41:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2716C194F4B3 for ; Fri, 19 Aug 2022 08:41:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id DF5E740D2827; Fri, 19 Aug 2022 08:41:25 +0000 (UTC) Received: from nautilus.redhat.com (unknown [10.40.193.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B1874010D45; Fri, 19 Aug 2022 08:41:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660898495; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=EmudL4/Cp8cKJHyxThVP+07mrtiHjMRQJGi/dfLyfaQ=; b=O+061fcdlUSsumDSJvRwcrB9nmFc5+LwRStKo2N8vSvP+sUbS5CAsehlCHLo28RAcvcAPm VI1DZyG08tdyTtbRwRpBoDphp01BfMNsdnTZcZskzjhILrTfoKtm8GDUNCVpW83RYxVN3L e9VVovlYX76cpdCccPIBByx4O6l/Suc= X-MC-Unique: Rk6DxGjoMrOojlJn8x8oUQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Erik Skultety To: libvir-list@redhat.com Subject: [libvirt PATCH] nwfilter: Fix timeout data type reported by coverity Date: Fri, 19 Aug 2022 10:41:24 +0200 Message-Id: <102ff9e0b4e68c4f42fdc8b78e3f855324bda533.1660898476.git.eskultet@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eskultet@redhat.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1660898497758100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Coverity reports: virNWFilterSnoopIPLeaseUpdate(virNWFilterSnoopIPLease *ipl, time_t timeout) { if (timeout < ipl->timeout) return; /* no take-backs */ virNWFilterSnoopIPLeaseTimerDel(ipl); >>> CID 396747: High impact quality (Y2K38_SAFETY) >>> A "time_t" value is stored in an integer with too few bits to accommodate it. The expression "timeout" is cast to "unsigned int". ipl->timeout =3D timeout; virNWFilterSnoopIPLeaseTimerAdd(ipl); } This is a safe fix, since time_t is just long int and scales automatically with platform (more specifically it's 64bit on all platforms we care about). Signed-off-by: Erik Skultety --- src/nwfilter/nwfilter_dhcpsnoop.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcp= snoop.c index a10a14cfc1..4133d4c672 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -146,7 +146,7 @@ struct _virNWFilterSnoopIPLease { virSocketAddr ipAddress; virSocketAddr ipServer; virNWFilterSnoopReq * snoopReq; - unsigned int timeout; + time_t timeout; /* timer list */ virNWFilterSnoopIPLease *prev; virNWFilterSnoopIPLease *next; @@ -1580,7 +1580,7 @@ virNWFilterSnoopLeaseFileWrite(int lfd, const char *i= fkey, return -1; =20 /* time intf ip dhcpserver */ - lbuf =3D g_strdup_printf("%u %s %s %s\n", ipl->timeout, ifkey, ipstr, = dhcpstr); + lbuf =3D g_strdup_printf("%lu %s %s %s\n", ipl->timeout, ifkey, ipstr,= dhcpstr); len =3D strlen(lbuf); =20 if (safewrite(lfd, lbuf, len) !=3D len) { @@ -1739,7 +1739,7 @@ virNWFilterSnoopLeaseFileLoad(void) } ln++; /* key len 54 =3D "VMUUID"+'-'+"MAC" */ - if (sscanf(line, "%u %54s %15s %15s", &ipl.timeout, + if (sscanf(line, "%lu %54s %15s %15s", &ipl.timeout, ifkey, ipstr, srvstr) < 4) { virReportError(VIR_ERR_INTERNAL_ERROR, _("virNWFilterSnoopLeaseFileLoad lease file " --=20 2.37.2